How can I override a .svc file in my routing table?

后端 未结 2 396
陌清茗
陌清茗 2020-12-24 12:11

I have this URL that was used from some JSON post back from the main website:

http://site/Services/api.svc/UpdateItem

We are in the process of updating the

相关标签:
2条回答
  • 2020-12-24 12:21

    The problem you're running into is due to a build provider that is registered for .svc files. This build provider is registered by the default machine level web.config file.

    In order to get routing to work in this case, you'll need to remove the build provider in your application's web.config file. The following snippet shows how to remove the .svc extension from the list of build providers.

      <system.web>
        <compilation debug="true" targetFramework="4.0">
            <buildProviders>
                <remove extension=".svc"/>            
            </buildProviders>
        ...
    
    0 讨论(0)
  • 2020-12-24 12:30

    Using URL Rewrites I was able to do what this link suggested, only backwards:

      <system.webServer>
        <rewrite>
          <rules>
            <rule name="LegacyApiService" stopProcessing="true">
              <match url="^Services/api.svc/(.*)$" />
              <action type="Rewrite" url="LegacyApi/{R:1}" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    
    0 讨论(0)
提交回复
热议问题