dimanche 1 février 2015

Routing in ASP.NET with numerical constraint path


Vote count:

0




I'm trying to route a specific path made of a numerical value and a string to a specific aspx page.


I have the following routing code initialized in the global.asax.cs file:



void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
void RegisterRoutes(RouteCollection routes)
{


routes.MapPageRoute("",
"{id}/{name}", "~/item.aspx",
true,
new RouteValueDictionary { { "id", @"\d+"} }
);

}


I have an item.aspx page as well.


When I try to access the page using this url:



http://localhost:8895/1/test/


I get 404 not found error. I am developing in ASP.NET 4.5/C#/Visual Studio 2013


What am I doing wrong?



asked 46 secs ago







Routing in ASP.NET with numerical constraint path

Aucun commentaire:

Enregistrer un commentaire