部署asp.net mvc iis6.0如何更改路由以包含.aspx
这是我的路由表,我在哪里放置各种“.aspx”注册?
//Turns off the unnecessary file exists check
this._Routes.RouteExistingFiles = true;
//Ignore text, html, xml files.
this._Routes.IgnoreRoute("{file}.txt");
this._Routes.IgnoreRoute("{file}.htm");
this._Routes.IgnoreRoute("{file}.html");
this._Routes.IgnoreRoute("{file}.xml");
//Ignore axd files such as assest, image, sitemap etc
this._Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//Ignore the assets directory which contains images, js, css & html
this._Routes.IgnoreRoute("Assets/{*pathInfo}");
//Ignore the error directory which contains error pages
this._Routes.IgnoreRoute("ErrorPages/{*pathInfo}");
//Exclude favicon (google toolbar request gif file as fav icon)
this._Routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.([iI][cC][oO]|[gG][iI][fF])(/.*)?" });
//Photo routes
this._Routes.MapRoute("PhotoAssets", "Photos/Photo/{photoId}/Size/{photoSizeClassificationId}", MVC.Photo.Photo(0, null));
//Handles department profile routes
this._Routes.MapRoute("WorkerProfileLeader", "Department/{departmentId}/Worker/Profile/Leader/List/{viewType}", MVC.WorkerProfile.List(PersonType.Leader, "", DisplayViewType.SummaryThumbnailList));
this._Routes.MapRoute("WorkerProfile", "Department/{departmentId}/Worker/Profile/{personType}/List/{viewType}", MVC.WorkerProfile.List(PersonType.Pleb, "", DisplayViewType.ThumbnailGrid));
this._Routes.MapRoute("WorkerProfilePerson", "Department/{departmentId}/Worker/Profile/{personType}/Detail/{personId}", MVC.WorkerProfile.Detail(PersonType.Pleb, "", ""));
//Default route mapping
this._Routes.MapRoute("Start", "Default.aspx", MVC.Home.Index());
this._Routes.MapRoute("Default", "{controller}/{action}", MVC.Home.Index());
干杯 安东尼
This is my routing tables where do I put the various '.aspx' registrations?
//Turns off the unnecessary file exists check
this._Routes.RouteExistingFiles = true;
//Ignore text, html, xml files.
this._Routes.IgnoreRoute("{file}.txt");
this._Routes.IgnoreRoute("{file}.htm");
this._Routes.IgnoreRoute("{file}.html");
this._Routes.IgnoreRoute("{file}.xml");
//Ignore axd files such as assest, image, sitemap etc
this._Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//Ignore the assets directory which contains images, js, css & html
this._Routes.IgnoreRoute("Assets/{*pathInfo}");
//Ignore the error directory which contains error pages
this._Routes.IgnoreRoute("ErrorPages/{*pathInfo}");
//Exclude favicon (google toolbar request gif file as fav icon)
this._Routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.([iI][cC][oO]|[gG][iI][fF])(/.*)?" });
//Photo routes
this._Routes.MapRoute("PhotoAssets", "Photos/Photo/{photoId}/Size/{photoSizeClassificationId}", MVC.Photo.Photo(0, null));
//Handles department profile routes
this._Routes.MapRoute("WorkerProfileLeader", "Department/{departmentId}/Worker/Profile/Leader/List/{viewType}", MVC.WorkerProfile.List(PersonType.Leader, "", DisplayViewType.SummaryThumbnailList));
this._Routes.MapRoute("WorkerProfile", "Department/{departmentId}/Worker/Profile/{personType}/List/{viewType}", MVC.WorkerProfile.List(PersonType.Pleb, "", DisplayViewType.ThumbnailGrid));
this._Routes.MapRoute("WorkerProfilePerson", "Department/{departmentId}/Worker/Profile/{personType}/Detail/{personId}", MVC.WorkerProfile.Detail(PersonType.Pleb, "", ""));
//Default route mapping
this._Routes.MapRoute("Start", "Default.aspx", MVC.Home.Index());
this._Routes.MapRoute("Default", "{controller}/{action}", MVC.Home.Index());
Cheers
Anthony
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需确保第一部分或 URL 以 .aspx 结尾,例如:
Just make sure the first part or the URL ends with .aspx like:
我很确定实际上 .aspx 在 URL 中的什么并不重要,只要它位于其中的某个位置并且是第一个看起来是文件扩展名的东西即可。 事实上,我见过的一个技巧是将 .aspx 放在包含应用程序的文件夹名称中! 换句话说,应用程序名称本身将是“myapp.aspx”,即使这只是一个文件夹。
只要 .aspx 作为路径中的第一个文件扩展名出现,IIS 就会使用该文件扩展名来处理请求。
I'm pretty sure it in fact doesn't matter where in the URL the .aspx is as long as it's somewhere in there and is the first thing that appears to be a file extension. In fact, one trick I've seen is to put the .aspx in the folder name containing the application! In other words, the application name itself would be "myapp.aspx" even though that's just a folder.
As long as .aspx appears as the first file extension in the path IIS will use that file extension to handle the request.