Reputation: 20001
I am trying to implement simple page routing, for some reason it is not working. I have cross checked almost everything but still nothing seems to works.
I list all the activities on Activities.aspx
& Show details of Activities of activity on Activity-Details.aspx
page.
link on Activities.aspx
page after URL Routing implementation are like
http://localhost:49442/website/en/activity/en-US/44/31/event-title-will-go-here
When i click on the link it always show me error message
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /website/en/activity/en-US/44/31/event-title-will-go-here
I am working on a multilingual website where i keep separate language specific files under particular folder English under en & Arabic under ar and folder structure like
/
/en
/en/Activities.aspx
/en/Activity-Details.aspx
...
/ar
/ar/Activities.aspx
/ar/Activity-Details.aspx
...
/images
/css
I have URL routing working for other projects but in this one i am missing something.
Code for Global.asax file
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RegisterRoutes(RouteTable.Routes);
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.Ignore("{resource}.exe/{*pathInfo}");
routes.MapPageRoute("ActivityRoute", "activity/{Language}/{EventID}/{PageID}/{EventTitle}", "~/en/Activity-Details.aspx", false,
new RouteValueDictionary {
{ "Language", "en-US"},
{ "EventID", "0" },
{ "PageID", "0"},
{ "EventTitle", "event-not-found" }},
new RouteValueDictionary {
{"Language", "[a-z]{2}-[a-z]{2}"},
{ "EventID", "[0-9]{1,8}" },
{ "PageID", "[0-9]{1,8}" }
});
}
WEB.Config Do i need to make any change to the web.config file for url routing to work. I have following entry in the web.config. I removed it but it is still not working..
<system.web>
<httpModules>
<add name="RoutingModule" type="System.Web.Routing.UrlRoutingModule"/>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
</system.web>
I have included using System.Web.Routing
on Activity-Details.aspx
page also. but i am not sure why i keep getting error.
Upvotes: 1
Views: 2469
Reputation: 24526
Install and enable Route Debugger. It will tell you which and why each route is(n't) being hit.
By the way, you don't have this part of your url mapped in your route: website/en/
Upvotes: 1