ASP.net URL重写到不同的域

时间:2015-06-16 10:35:28

标签: asp.net azure url-rewriting

我正在尝试重写为azure中的blob中的url以返回静态html,但它始终指出以下404.4错误:

  

请求的URL的文件扩展名没有处理程序   配置为在Web服务器上处理请求。

  • 模块:IIS Web Core
  • 通知:MapRequestHandler
  • 处理程序:StaticFile
  • 错误代码:0x8007007b

这是我的web.config文件:

  <system.web>
    <authentication mode="None" />
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <httpHandlers>
      <add path="*.html" verb="*" type="System.Web.StaticFileHandler" />
    </httpHandlers>
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <validation validateIntegratedModeConfiguration="false" />

    <staticContent>
      <remove fileExtension=".css" />
      <mimeMap fileExtension=".css" mimeType="text/css; charset=UTF-8" />
      <remove fileExtension=".js" />
      <mimeMap fileExtension=".js" mimeType="text/javascript; charset=UTF-8" />
      <remove fileExtension=".json" />
      <mimeMap fileExtension=".json" mimeType="application/json; charset=UTF-8" />
      <remove fileExtension=".rss" />
      <mimeMap fileExtension=".rss" mimeType="application/rss+xml; charset=UTF-8" />
      <remove fileExtension=".html" />
      <mimeMap fileExtension=".html" mimeType="text/html; charset=UTF-8" />
      <remove fileExtension=".xml" />
      <mimeMap fileExtension=".xml" mimeType="application/xml; charset=UTF-8" />
    </staticContent>

    <rewrite>
      <rules>
        <rule name="static" stopProcessing="true">
          <match url="static/(.*)" />
          <action type="Rewrite" url="https://www.blobtest.blob.core.windows.net/static/{R:1}" />
        </rule>
      </rules>
    </rewrite>

  </system.webServer> 

我添加了一个httphandler和mimemaps,仍然显示相同的错误。此外,如果我将重写更改为重定向它可以工作,但这会更改我不想要的网址。

提前致谢。

1 个答案:

答案 0 :(得分:3)

我今天刚遇到同样的问题而且事实证明这是因为URL重写只有在您明确地在同一个站点/ Web应用程序中重定向时才有效。有关解决方案,请参阅http://blogs.msdn.com/b/asiatech/archive/2011/08/25/return-404-4-not-found-when-url-rewrite.aspx。提示:您需要安装ARR并在ARR下选中“启用代理”框 - &gt;服务器代理设置

希望它会对你有所帮助。如果为时已晚,从互联网上有这个问题的人数来判断,我相信它会帮助其他人

相关问题