1. Add the following handler to your web.config
<system.webServer> <handlers> <add name="ApiURIs-ISAPI-Integrated-4.0_2" path="/products/*" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /> </handlers> </system.webServer>
Here I am assuming that the url’s that contains dots in your case is starting from /products/urlwith.adot. A drawback is as soon as you set path to [path="*"] all requests to static files such as .pdf, .js, .css etc fails.
2. RunAllManagedModulesForAllRequests
<system.webserver> <modules runAllManagedModulesForAllRequests="true">
Drawback is performance hit as it enables all managed modules for static requests as well such as for .pdf, .js, .css etc. So everything gets processed by .NET even if it is not required.
3. relaxedUrlToFileSystemMapping
<system.web> <httpRuntime relaxedUrlToFileSystemMapping="true" />
Drawback is that it does not work with newer versions of MVC.
Easiest Solution to allows dots in ASP.NET MVC Paths
One of the easiest solutions to allows dots in path names is the following:Open IIS Manager (inetmgr) > Go the site or folder
Open URL Rewrite
In the right hand column, from the Action Pane Click on ‘Add Rule(s)’. In the Search Engine Optimization (SEO) Section, click on “Append or remove the trailing slash symbol” > Choose the default option “Appended if it does not exist” and click ok.
This creates an entry in your web.config file as follows:
<rewrite> <rules> <clear /> <rule name="AddTrailingSlashRule1" stopProcessing="true"> <match url="(.*[^/])$" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> </conditions> <action type="Redirect" url="{R:1}/" /> </rule> </rules> </rewrite>
And that’s it. This rule allows dots in MVC paths as well as keeps Search engines happy by creating a redirect rule that will enforce the use of the trailing slash symbol in the URL.
Thanks a ton !
ReplyDeletei needed all three settings to get it work - nowhere else was all three listed !
None of them is working for me.
ReplyDeleteThanks for the summary.
ReplyDeleteI used your last suggestion.
In IIS 8.5 (.Net 4.6) the path should be without first slash: path="products/*"
ReplyDeleteThanks for posting this. But when I use this my POST methods are not working. Any suggestion/help?
ReplyDelete@Raju MVC 4 or 5?
ReplyDelete