2011-05-13 14 views
3

我有谁与在Global.asax中添加自定义路线一个网页(他们是无扩展名)的客户端:IIS 7.5路由不工作(所有常用方法进行测试)

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) 
Routing.RouteTable.Routes.Clear() 
Routing.RouteTable.Routes.MapPageRoute("Key1", "String", "~/Route") 

不幸的是这重定向不在IIS 7.5上工作。我测试了:

  • HTTP重定向安装在IIS
  • 试过runAllManagedModulesForAllRequests = “真”(在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> 

回答

1

我的解决办法,尝试后一切:

糟糕的部署,旧的PrecompiledApp.config挂在我的部署位置,并使一切都不工作。

我认为工作最终设置:

  • IIS 7.5,Win2k8r2 64,在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> 
    
  • Global.ashx:(仅适用于任何音符的方法)

    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); 
    } 
    
  • PassthroughRouteHandler .cs - 实现了从http://andrew.arace.info/stackoverflowhttp://andrew.arace.info/#stackoverflow的自动转换,然后由默认处理。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; 
        } 
    } 
    
1
+0

¡感谢IrishChieftain!但遗憾的是这正是我已经张贴和前检查的链接。我试图在发布之前解决问题。 – IoChaos 2011-05-13 14:17:29

+0

你可以具体说明这个项目的类型 - Web Form应用程序项目吗? MVC页面是在一个单独的项目中,还是你想混合它们(不推荐)? – IrishChieftain 2011-05-13 14:54:22

+0

IrishChieftain,再次感谢:)。使用路由的Webforms。 – IoChaos 2011-05-13 17:52:21