0

我已经使 asp.net 中的路由正常工作。但是,如果我使用 Default.aspx 键入地址,它仍然超出了我的路由并点击了页面。

2)以及对于我的应用程序的第一个请求没有击中路由处理程序。即当 http://localhost:8080/(使用 Visual Studio 服务器)没有击中所以我无法正确呈现第一页

4

1 回答 1

0

为什么需要处理 default.aspx?如果您引用网站的根目录,例如:

Response.Redirect("~/");

// or

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

地址已正确解析。那么如果有人想输入 default.aspx 怎么办,因为这是他们到达那里并在地址栏中显示 default.aspx 的唯一方法。这里到底有什么问题?

至于你的第二个问题,可能是Web.config中的配置问题。确保您在 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>
于 2011-05-07T15:17:56.720 回答