Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
804 views
in Technique[技术] by (71.8m points)

asp.net mvc - Considerations when turning on RouteExistingFiles

I am looking to generate some CSS files dynamically in my Content folder.

At the moment, this folder has an ignore route (routes.IgnoreRoute("Content/{*wildcard}");) and, I'd like that to remain, as I don't need/want most of my content folders to go into the MVC request lifecycle.

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 questions/concerns about this setup:

  • Will this work? Routes in ASP.NET MVC are lazy, but I don't know if the ignore routes are checked first. There's no documentation (I've Googled!) on this form of usage.
  • Are there any security implications to consider when switching on RouteExistingFiles? I don't want IIS to pick up any of my Model/Views folders by directly referencing them.

Many thanks for any suggestions.

Edit:

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Scott Hanselman got a blog post "Plug-In Hybrids: ASP.NET WebForms and ASP.MVC and ASP.NET Dynamic Data Side By Side" in which he talked about his too. http://www.hanselman.com/blog/PlugInHybridsASPNETWebFormsAndASPMVCAndASPNETDynamicDataSideBySide.aspx

Hope this helps,

Ray.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...