Reputation: 53
I'm running into a bit of an issue. My postbacks are causing my asp.net application pages to jump back to the top of the page even though they are inside update panels.
when i use this routing updatepanel stop working
void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.MapPageRoute("UProfile", "{ID}", "~/UProfile.aspx");
}
but when i use this code it works fine, but i want the simplest URL
void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.MapPageRoute("UProfile", "Users/{ID}", "~/UProfile.aspx");
how should i solve this problem ? I have tried a couple different solutions, that did not work:
1) http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
2) http://www.iis.net/learn/extensions/url-rewrite-module/url-rewriting-for-aspnet-web-forms
Upvotes: 0
Views: 658
Reputation: 5989
This will route will target root Url because there is no any specific identifier to map it properly. I will rather suggest to write a route constraint so you can decide when to use the user details page after validating the passed parameter. You can add routers in Asp.net Webforms too. Check the following link. http://www.shubho.net/2011/02/aspnet-mvp-url-routing-webforms-part3.html
The possible solution would be...
RouteTable.Routes.MapPageRoute("UProfile",
"{ID}",
"~/UProfile.aspx",
false,
new RouteValueDictionary { { "ID", "1" } }, new RouteValueDictionary { { "ID", "[\d]+" } });
Upvotes: 0