0

我无法弄清楚如何使它工作,在互联网上搜索..这是我的代码

  void Application_Start(object sender, EventArgs e)
    {
        // Code that runs on application startup
        RegisterRoutes(RouteTable.Routes);
    }
void RegisterRoutes(RouteCollection routes)
    {
        //routes.MapPageRoute("Default", "agent/{name}", "~/agent/default.aspx");
        routes.MapPageRoute("Default", "agent/{name}", "~/agent/default.aspx", false, new RouteValueDictionary { { "name", String.Empty } });
    }

我的 Web.config 文件

 <system.web>
    <compilation debug="true" targetFramework="4.0" >
      <assemblies>
        <add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

      </assemblies>
    </compilation>

    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
    </authentication>
    <membership>
      <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
             enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
             maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
             applicationName="/" />
      </providers>
    </membership>

    <profile>
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
      </providers>
    </profile>`enter code here`

    <roleManager enabled="false">
      <providers>
        <clear/>
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
      </providers>
    </roleManager>
    <customErrors mode="Off"/>
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">

    </modules>
    <modules>
      <remove name="UrlRoutingModule" />
      <add name="UrlRoutingModule"
           type="System.Web.Routing.UrlRoutingModule, 
               System.Web.Routing, 
               Version=4.0.0.0, 
               Culture=neutral, 
               PublicKeyToken=31BF3856AD364E35"/>
    </modules>
  </system.webServer>
</configuration>

我在互联网上搜索了很多 asp.net 网络表单路由,完成了所有步骤等,但无法使其工作。任何帮助将不胜感激。

4

2 回答 2

4

试试这个 web.config

<system.webServer>
  <validation validateIntegratedModeConfiguration="false" />
  <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" />
</handlers>
</system.webServer>
于 2013-12-26T07:28:33.290 回答
0

就我而言,我没有在服务器上复制以下文件:

预编译的App.config

添加后,重新启动 IIS 工作表。

于 2016-06-23T06:28:50.690 回答