简体   繁体   English

ASP.net URL重写到不同的域

[英]ASP.net URL rewrite to a different domain

I am trying to rewrite to a url in a blob in azure to return a static html but it always states the following 404.4 error: 我试图重写为azure中的blob中的url以返回静态html,但它始终指出以下404.4错误:

The file extension for the requested URL does not have a handler configured to process the request on the Web server. 请求的URL的文件扩展名没有配置为在Web服务器上处理请求的处理程序。

  • Module: IIS Web Core 模块:IIS Web Core
  • Notification: MapRequestHandler 通知:MapRequestHandler
  • Handler:StaticFile 处理器:StaticFile
  • Error Code: 0x8007007b 错误代码:0x8007007b

Here is my web.config file: 这是我的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> 

I have added an httphandler and mimemaps and still displays the same error. 我添加了一个httphandler和mimemaps,仍然显示相同的错误。 Also if I change Rewrite to Redirect it works but this changes the url which I don't want. 此外,如果我将重写更改为重定向它可以工作,但这会更改我不想要的网址。

Thanks in advance. 提前致谢。

I just faced the same issue today and it turns out it's because URL rewrite only works if you redirect within the same site / web app apparently. 我今天刚刚遇到了同样的问题,事实证明这是因为URL重写只有在你明确地在同一个站点/ web应用程序中重定向时才有效。 See http://blogs.msdn.com/b/asiatech/archive/2011/08/25/return-404-4-not-found-when-url-rewrite.aspx for a solution. 有关解决方案,请参见http://blogs.msdn.com/b/asiatech/archive/2011/08/25/return-404-4-not-found-when-url-rewrite.aspx hint: you need ARR installed and the "Enable Proxy" box checked under ARR -> Server Proxy Settings 提示:您需要安装ARR并在ARR - >服务器代理设置下选中“启用代理”框

Hopefully it will help you. 希望它会对你有所帮助。 And if it's too late, well judging by the number of people with that issue on the internet, I'm sure it will help others 如果为时已晚,从互联网上有这个问题的人数来判断,我相信它会帮助别人

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM