If we are using ASP.NET URL rewriting concept, you might Registered routes correctly in Global.aspx like below
protected void Application_Start(object
sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
public static void
RegisterRoutes(RouteCollection
routeCollection)
{
routeCollection.MapPageRoute("RouteArticle", "Articles/{Id}", "~/Resources/ViewArticle.aspx");
}
|
ViewArticle.aspx.cs:
int resourceContentID
= int.Parse(Page.RouteData.Values["Id"].ToString());
From the browser if you try to access the page(http://localhost/website/articles/13) ,sometimes we will get run time error as Page.RouteData as null or HTTP page not found in browser.
In order to avoid the error add below section to web.config file.
<configuration>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
0 Comments:
Post a Comment