In our ASP.NET MVC application, we've noticed that we cannot have The Forbidden DOS File Names—COM1
through COM9
, LPT1
through LPT9
, CON
, AUX
, PRN
, and NUL
—anywhere in our routes. They inevitably result in IIS telling us the file cannot be found, even when we set routing not to check for the existence of files first. How can we work around this?
There are reserved words that can't be used as route segments or parameter names.
In MVC, routing is a process of mapping the browser request to the controller action and return response back. Each MVC application has default routing for the default HomeController. We can set custom routing for newly created controller. The RouteConfig. cs file is used to set routing for the application.
Multiple Routes You need to provide at least two parameters in MapRoute, route name, and URL pattern. The Defaults parameter is optional. You can register multiple custom routes with different names.
This has been addressed in ASP.NET 4. http://haacked.com/archive/2010/04/29/allowing-reserved-filenames-in-URLs.aspx
You can apply a setting in web.config that relaxes this restriction.
<configuration> <system.web> <httpRuntime relaxedUrlToFileSystemMapping="true"/> <!-- ... your other settings ... --> </system.web> </configuration>
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With