Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net IIS 7.5路由不工作(测试了所有常用方法)_Asp.net_Routing_Iis 7.5 - Fatal编程技术网

Asp.net IIS 7.5路由不工作(测试了所有常用方法)

Asp.net IIS 7.5路由不工作(测试了所有常用方法),asp.net,routing,iis-7.5,Asp.net,Routing,Iis 7.5,我有一个客户,他在global.asax中添加了一个带有自定义路由的网页(无扩展): 不幸的是,此重定向在IIS 7.5上不起作用。我已经测试过: HTTP重定向是通过IIS安装的 尝试运行AllManagedModulesForallRequests=“true”(在web.config中) 使用UrlRoutingMode的手动添加(http://www.britishdeveloper.co.uk/2010/06/dont-use-modules-runallmanagedmodules

我有一个客户,他在global.asax中添加了一个带有自定义路由的网页(无扩展):

不幸的是,此重定向在IIS 7.5上不起作用。我已经测试过:

  • HTTP重定向是通过IIS安装的
  • 尝试运行AllManagedModulesForallRequests=“true”(在web.config中)
  • 使用UrlRoutingMode的手动添加(http://www.britishdeveloper.co.uk/2010/06/dont-use-modules-runallmanagedmodulesfo.html)
池处于集成模式,4.0。此服务器正在运行大量MVC3页面,默认情况下它们使用路由

任何光线都将非常珍贵!谢谢

======================================================================

编辑:好的,我找不到任何解决方案

在webconfig中的程序集内部:

<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

在system.webServer上:

<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<defaultDocument>
<files><add value="Page.aspx" /></files>
</defaultDocument>
<modules runAllManagedModulesForAllRequests="true">
<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>

看看这个:


我的解决方案,在尝试了所有方法之后:

糟糕的部署,一个旧的预编译app.config挂在我的部署位置上,使一切都无法工作

我的最终设置有效:

  • IIS 7.5,Win2k8r2 x64
  • 集成模式应用程序池
  • web.config中没有任何更改-这意味着没有用于路由的特殊处理程序。这是我的快照,有很多其他文章参考。我正在使用FluorineFX,因此我添加了该处理程序,但我不需要任何其他处理程序:

    <system.web>
      <compilation debug="true" targetFramework="4.0" />
      <authentication mode="None"/>
    
      <pages validateRequest="false" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
      <httpRuntime requestPathInvalidCharacters=""/>
    
      <httpModules>
        <add name="FluorineGateway" type="FluorineFx.FluorineGateway, FluorineFx"/>
      </httpModules>
    </system.web>
      <system.webServer>
        <!-- Modules for IIS 7.0 Integrated mode -->
        <modules>
          <add name="FluorineGateway" type="FluorineFx.FluorineGateway, FluorineFx" />
        </modules>
    
        <!-- Disable detection of IIS 6.0 / Classic mode ASP.NET configuration -->
        <validation validateIntegratedModeConfiguration="false" />
      </system.webServer>
    
  • PassthroughRouteHandler.cs-这实现了从到的自动转换,然后将由default.aspx处理:

    public class PassthroughRouteHandler : IRouteHandler {
    
        public IHttpHandler GetHttpHandler(RequestContext requestContext) {
            HttpContext.Current.Items["IncomingMessage"] = requestContext.RouteData.Values["message"];
            requestContext.HttpContext.Response.Redirect("#" + HttpContext.Current.Items["IncomingMessage"], true);
            return null;
        }
    }
    

“谢谢爱尔兰酋长!”!,但不幸的是,这正是我之前发布和检查过的链接。在发布之前,我已经试着解决了这个问题。您能具体说明一下这个项目的类型吗?Web表单应用程序项目?MVC页面是在一个单独的项目中,还是您正在尝试混合它们(不推荐)?给RouteMagic一个机会?再次感谢,我不能修改应用程序,只要我只是托管它。不知道为什么,但是当没有ASPX页面时,IIS无法管理请求。我将尝试使用经典模式。
void Application_Start(object sender, EventArgs e) {
    // Register routes...
    System.Web.Routing.Route echoRoute = new System.Web.Routing.Route(
          "{*message}",
        //the default value for the message
          new System.Web.Routing.RouteValueDictionary() { { "message", "" } },
        //any regular expression restrictions (i.e. @"[^\d].{4,}" means "does not start with number, at least 4 chars
          new System.Web.Routing.RouteValueDictionary() { { "message", @"[^\d].{4,}" } },
          new TestRoute.Handlers.PassthroughRouteHandler()
       );

    System.Web.Routing.RouteTable.Routes.Add(echoRoute);
}
public class PassthroughRouteHandler : IRouteHandler {

    public IHttpHandler GetHttpHandler(RequestContext requestContext) {
        HttpContext.Current.Items["IncomingMessage"] = requestContext.RouteData.Values["message"];
        requestContext.HttpContext.Response.Redirect("#" + HttpContext.Current.Items["IncomingMessage"], true);
        return null;
    }
}