Rewrite rule for WebAPI fails because of ExtensionlessUrlHandler

有些话、适合烂在心里 提交于 2019-12-31 03:04:31

问题


I am attempting to use IIS to rewrite requests from my ASP.net MVC 4 application to my ASP.net MVC 4 WebApi. From the client, I am using ajax to make calls back to the server which I would then like the server to rewrite the request to point to the webapi site. This should solve any cross domain issues if I can get it to work.

I have installed URL rewrite, Web Farm Framework, ARR, and External Cache per this article: http://blogs.iis.net/wonyoo/archive/2011/04/20/how-to-install-application-request-routing-arr-2-5-without-web-platform-installer-webpi.aspx

In IIS->Application Request Routing->Server Proxy Settings" and checked the box that says "Enable proxy".

My rewrite rule looks like:

<rule name="webapi" stopProcessing =" true" >
  < match url =" webapi/(.*)" />
  < conditions>
    < add input =" {HTTP_HOST}" pattern="web(\.mytest\.com)$" />
  </ conditions>
  < action type =" Rewrite" url= "http://api{C:1}/api/{R:1} " />
</ rule>

What is really curious if I remove the ExtensionlessUrlHandlers in the web.config of my MVC site, then my rewrite works perfectly. Unfortunately, the MVC routing breaks and my site no longer works. If put the ExtensionlessUrlHandlers back in, the rewrite fails and the MVC routing works as expected.

Is there a simple way to solve this issue?

来源:https://stackoverflow.com/questions/13885343/rewrite-rule-for-webapi-fails-because-of-extensionlessurlhandler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!