开发者

Combining ASP.NET MVC and Reverse Proxy with URL Rewrite v2

开发者 https://www.devze.com 2023-01-08 09:22 出处:网络
I have a need to submit some data to a different host name and was hoping to utilize the reverse proxy guide found here for IIS 7.5

I have a need to submit some data to a different host name and was hoping to utilize the reverse proxy guide found here for IIS 7.5

http://learn.iis.net/page.aspx/659/reverse-proxy-with-url-rewrite-v2-and-application-request-routing/

I have added the following code to my system.webserver entry in the site's root w开发者_运维技巧eb.config

<system.webServer>
        <urlCompression doStaticCompression="true" doDynamicCompression="true" />
        <staticContent>
            <remove fileExtension=".js" />
            <mimeMap fileExtension=".js" mimeType="text/javascript" />
        </staticContent>
        <validation validateIntegratedModeConfiguration="false" />
        <modules runAllManagedModulesForAllRequests="true">
            <remove name="ScriptModule" />
            <remove name="UrlRoutingModule" />
            <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        </modules>
        <handlers>
            <remove name="WebServiceHandlerFactory-Integrated" />
            <remove name="ScriptHandlerFactory" />
            <remove name="ScriptHandlerFactoryAppServices" />
            <remove name="ScriptResource" />
            <remove name="MvcHttpHandler" />
            <remove name="UrlRoutingHandler" />
            <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
            <add name="AssetHandler" preCondition="integratedMode" verb="GET,HEAD" path="asset.axd" type="Telerik.Web.Mvc.WebAssetHttpHandler, Telerik.Web.Mvc"/>
            <add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode"/>
        </handlers>
      <rewrite>
        <rules>
          <rule name="Reverse Proxy to spellchecker" stopProcessing="true">
            <match url="^spellchecker/(.*)" />
            <action type="Rewrite" url="http://spellcheck001.XXX.yyy/{R:1}" logRewrittenUrl="true" />
          </rule>
        </rules>
      </rewrite>
    </system.webServer>

Can you not combine the built in rewrite module with MVC? I have tried google and found no straightforward answer. If I attempt to access a url within the spellchecker path I receive a 404 response.


I had the same problem and did not find a solution. At the end I used http://urlrewriter.codeplex.com. This module handles pretty high load on our server and we did not have any problem with it yet.

0

精彩评论

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

关注公众号