Reputation: 1
I've been trying to figure out how to get URL routing to work on my box all evening. I'm pretty sure I'm doing things according to the online tutorials (http://msdn.microsoft.com/en-us/library/vstudio/dd329551%28v=vs.100%29.aspx) but for some reason it's not working.
This is what I currently type in the address bar: /MA1/DoSurvey.aspx?id=42
But I want the URL to work like this: /MA1/DoSurvey/42
According to the tutorial I have to modify:
RouteConfig.RegisterRoutes(RouteTable.Routes);
into the Application_Start method
routes.MapPageRoute("","DoSurvey/{id}","~/MA1/DoSurvey.aspx");
into the RegisterRoutes method
using System.Web.Routing;
as a reference in the DoSurvey.aspx page and then
string SurveyIdQueryStringValue = Page.RouteData.Values["id"] as string;
in the DoSurvey.aspx page
what am I missing?
Upvotes: 0
Views: 757
Reputation: 36
I Add this code to web.config and everything worked fine, try it
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRoutingModule" />
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</modules>
<handlers>
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
Upvotes: 1