开发者

ASP.NET and Custom Routing to the default page

开发者 https://www.devze.com 2023-03-04 18:40 出处:网络
I have made the routing in asp.net to work correctly .But still if i type the Address with Default.aspx it\'s surpassing my routes and hitting the Page.

I have made the routing in asp.net to work correctly .But still if i type the Address with Default.aspx it's surpassing my routes and hitting the Page.

2)As well as F开发者_StackOverflow社区or the First request of my application is not hitting the route handler .ie when http://localhost:8080/ (using visual studio server) is not hitting so i am not able to render the first page correctly


Why do you need to handle default.aspx? If you refer to the root of your website like:

Response.Redirect("~/");

// or

<a runat="server" href="~/">Home</a>

The address is resolved correctly. So what if someone wants to type in default.aspx, since that's the only way they will get there and have default.aspx show in the address bar. What exactly is the problem here?

As for your second question, it might be a configuration problem in the Web.config. Make sure you have the following in WEb.config:

<configuration>
<system.web>
  <compilation debug="true" targetFramework="4.0">
    <assemblies>
    <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </assemblies>
  </compilation>
</system.web>
<system.webServer>
  <modules runAllManagedModulesForAllRequests="true">
  </modules>
</system.webServer>
</configuration>
0

精彩评论

暂无评论...
验证码 换一张
取 消