1

I am trying to do a simple IIS Rewrite of a URL from a WebAPI service call to an .asmx web service call. Here is my configuration added to my WebAPI web.config after setting up in IIS:

  <system.webServer>
     <rewrite>
        <rules>
           <rule name="Rewrite Proxy To Client" patternSyntax="ExactMatch">
              <match url="api/MyWebAPIProxy" />
              <action type="Rewrite" url="http://localhost/MyWebService.asmx/MyServiceMethod" logRewrittenUrl="true" />
           </rule>
        </rules>
     </rewrite>
  </system.webServer>

I tried everything from here (URL rewrite - web.config error) including re-installing the IIS rewrite module and it did not help. I get the following error when I call the WebAPI service that contains this configuration:

HTTP Error 500.52 - URL Rewrite Module Error. The configuration section 'system.webServer/rewrite/allowedServerVariables' cannot be read because it is missing a section declaration

Now I can call the services independently using say Postman or Fiddler and the services work well. Actually before I can call the WebAPI service that has the IIS rewrite rule, I have to remove the configuration for the rewrite and then call. The point is, the services both work. The issue is something with this rewrite configuration. What am I doing incorrectly here that is not causing this to work?

Community
  • 1
  • 1
atconway
  • 20,624
  • 30
  • 159
  • 229

0 Answers0