Considerations When Enabling RouteExistingFiles

I want to generate some CSS files dynamically in the Content folder.

There is currently an ignore route in this folder ( routes.IgnoreRoute("Content/{*wildcard}"); ), and I would like it to stay as I don't need / want most of my content folders to go to MVC request life cycle.

Example:

  routes.MapRoute( "DynamicCSS", "Content/Css/Dynamic/{guid}.css", new { controller = "Site", action = "GenerateCSS" }, new { guid = @"^([0-9a-fA-F]){8}([0-9a-fA-F]){4}([0-9a-fA-F]){4}([0-9a-fA-F]){4}([0-9a-fA-F]){12}$" } ); //If the file has already been generated, IIS should just return the file, saving a request in MVC. routes.RouteExistingFiles = true; //was formerly false //Ignore routes routes.IgnoreRoute("Content/{*wildcard}"); 

I have a couple of questions / issues related to this setting:

  • Will this work? Routes in ASP.NET MVC are lazy, but I don’t know if ignore routes are checked first. There is no documentation (I'm Googled!) In this form of use.
  • Are there any security implications when enabling RouteExistingFiles ? I do not want IIS to collect any of my Model / Views folders by referencing them directly.

Thanks so much for any suggestions.

Edit:

After further research, I found an article on my first problem.

+4
source share
1 answer

Scott Hanselman received a blog post, "Plug-in Hybrids: ASP.NET WebForms and ASP.MVC and ASP.NET Dynamic Data Around," in which he also talked about him. http://www.hanselman.com/blog/PlugInHybridsASPNETWebFormsAndASPMVCAndASPNETDynamicDataSideBySide.aspx

Hope this helps,

Ray

+3
source

Source: https://habr.com/ru/post/1303462/


All Articles