views:

25

answers:

2

I am trying to add page routing (I use regular asp.net 4.0, not mvc), so that when a user goes to:

http://sitename.com/public/member/view/andrey

they would get to: http://sitename.com/public/memberprofile.aspx?userName=andrey

I added following in Global.asax:

protected void Application_Start(object sender, EventArgs e)
{
    RouteTable.Routes.MapPageRoute("MemberViewRoute",
        "Public/View/Member/{username}",
        "~/Public/MemberProfile.aspx");
}

But when I try going to http://sitename.com/public/member/view/andrey in my browser, I get 404

Is there anything else that needs to be done for this routing to work other than adding a page route map?

Thanks!

+1  A: 

Your route says Public/View/Member/{username}
But your link is /public/member/view/andrey

This would definitely 404

Why not try and change your route to

protected void Application_Start(object sender, EventArgs e)
{
    RouteTable.Routes.MapPageRoute("MemberViewRoute",
        "Public/Member/View/{username}",
        "~/Public/MemberProfile.aspx");
}

and see what happens

rockinthesixstring
Good catch, but it still hasn't worked. As I found, I needed to add HTTP redirect feature to IIS and a handler entry to web.config
Andrey
A: 

I actually found this great article that helped me fix my problem: http://blogs.msdn.com/b/rjacobs/archive/2010/06/30/system-web-routing-routetable-not-working-with-iis.aspx

Andrey