【问题标题】:Deploying asp.net mvc iis6.0 how to change route TO include .aspx部署asp.net mvc iis6.0如何将路由更改为包含.aspx
【发布时间】:2009-07-07 04:52:24
【问题描述】:

这是我的路由表,我将各种“.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());

干杯 安东尼

【问题讨论】:

  • 您不想设置通配符吗?如 phil haack 所述

标签: asp.net-mvc asp.net-mvc-routing url-routing


【解决方案1】:

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

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

【讨论】:

  • 干杯这就是我想知道的
【解决方案2】:

我很确定实际上 .aspx 在 URL 中的位置并不重要,只要它在其中的某处并且是第一个看起来是文件扩展名的东西。事实上,我见过的一个技巧是将 .aspx 放在包含应用程序的文件夹名称中!换句话说,应用程序名称本身就是“myapp.aspx”,即使它只是一个文件夹。

只要 .aspx 作为路径中的第一个文件扩展名出现,IIS 就会使用该文件扩展名来处理请求。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-13
    • 1970-01-01
    • 1970-01-01
    • 2011-02-01
    • 1970-01-01
    • 2016-10-03
    • 2021-01-30
    相关资源
    最近更新 更多