Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC Routing vs. Reserved Filenames in Windows

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?

like image 494
Benjamin Pollack Avatar asked Jun 12 '09 14:06

Benjamin Pollack


People also ask

Can we use ASP net core reserved keywords as route names?

There are reserved words that can't be used as route segments or parameter names.

What is MVC routing?

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.

Can we have multiple routing in MVC?

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.


1 Answers

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.

like image 166
Haacked Avatar answered Sep 28 '22 03:09

Haacked