MVC3地图路线静态文件结构 [英] MVC3 map routes to static file structure
问题描述
让我们说我有,根据标准/ {}控制器请求路由/ {}行动模式的MVC应用程序。我也想从嵌套目录结构能够返回静态文件。例如,我希望根网址:
/MyApplication/Static/folder/subfolder/somefile.xml
在物理位置〜/静态/文件夹/子文件夹/ somefile.xml返回文件,等等。
这是对的MapPageRoute的方法是什么呢?如果是的话,是有可能做这样的事情?
routes.MapPageRoute(static_file_router,静态/ *,〜/静态/ *)
我认为你应该使用IIS,而不是图这一点。静态文件不需要去通过ASP.NET管道,并请求不必要的减速。
的MapPageRoute
是传统的WebForms页。
例如。
routes.MapPageRoute(,
SalesReport / {区域设置} / {每年} / {*} queryvalues
〜/ sales.aspx);
请参阅的http://msdn.microsoft.com/en-us/library/system.web.routing.routecollection.mappageroute.aspx
Let's say I have an MVC application that routes requests according to the standard /{controller}/{action} pattern. I also want to be able return static files from a nested directory structure. For example, I want the root URL:
/MyApplication/Static/folder/subfolder/somefile.xml
to return the file at the physical location ~/Static/folder/subfolder/somefile.xml, and so on.
Is this what the "MapPageRoute" method is for? If so, is it possible to do something like this?
routes.MapPageRoute("static_file_router", "Static/*", "~/Static/*")
I think you should use IIS to map this instead. Static files don't need to go through the ASP.NET pipeline and slow down the requests unnecessarily.
MapPageRoute
is for legacy WebForms pages.
e.g.
routes.MapPageRoute("",
"SalesReport/{locale}/{year}/{*queryvalues}",
"~/sales.aspx");
See http://msdn.microsoft.com/en-us/library/system.web.routing.routecollection.mappageroute.aspx
这篇关于MVC3地图路线静态文件结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!