Anyway, I'm happy that this can be achieved easily by using the URL Rewrite feature of IIS 8. For IIS 7 and 7.5, you will need to download it separately here. To enable URL Rewrites, simply include a section like this in your web.config file.
<system.webServer>The above rewrite rule basically rewrites any call to MyService.aspx to MyService.svc. If you prefer to use the UI, you can access it via the IIS Manager as well. Just look for a URL Rewrite icon in the Feature View.
<rewrite>
<rules>
<rule name="AspxToSvc">
<match url="^MyService.aspx(.*)$" />
<action type="Rewrite" url="MyService.svc/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
Everything should work fine with the above configuration but if you are unlucky like me who may have messed up the IIS 8 installation earlier, here's what you can do. From IIS Manager, go to your web server and then open the Modules from Feature View.
Make sure you have a RewriteModule with the path %windir%\System32\inetsrv\rewrite.dll in there. If not, just click on Configure Native Modules... and add it in yourself.
With this, any service consumer that calls your REST-based WCF service will be able to access it with a .aspx extension. Of course my recommendation would be to do away with the extension if possible.
Note: If you are interested to make your WCF to be backward compatible with old-style applications that expects custom response formats from calling ASPX, you may want to read my post on WCF WebHttpBinding Custom WebMessageFormat.
No comments:
Post a Comment