部署asp.net mvc iis6.0如何更改路由以包含.aspx

发布于 2024-07-27 03:05:53 字数 1779 浏览 6 评论 0原文

这是我的路由表,我在哪里放置各种“.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我为君王 2024-08-03 03:05:53

只需确保第一部分或 URL 以 .aspx 结尾,例如:

this._Routes.MapRoute("WorkerProfileLeader", "Department.aspx/{departmentId}/Worker/Profile/Leader/List/{viewType}", ...
this._Routes.MapRoute("Default", "{controller}.aspx/{action}", MVC.Home.Index());

Just make sure the first part or the URL ends with .aspx like:

this._Routes.MapRoute("WorkerProfileLeader", "Department.aspx/{departmentId}/Worker/Profile/Leader/List/{viewType}", ...
this._Routes.MapRoute("Default", "{controller}.aspx/{action}", MVC.Home.Index());
我的影子我的梦 2024-08-03 03:05:53

我很确定实际上 .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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文