public class MvcApplication : System.Web.HttpApplication {
public static void RegisterRoutes(RouteCollection routes) {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute(
"Default", // Route name
"{controller}.aspx/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
// 原先是{controller}/{action}/{id} 给加了个后缀之后
// 之前的Default.aspx(默认的起始页)运行时就会报“传入的请求不与任何路由匹配。”
// 因为是在iis6下发布的 所以要加个后缀
// 也刚学这个不知道为什么会出现这问题 请问谁能帮忙看下?
} protected void Application_Start() {
RegisterRoutes(RouteTable.Routes);
}
}// 这是Default.aspx.cs里边默认的代码
public void Page_Load(object sender, System.EventArgs e) {
// Change the current path so that the Routing handler can correctly interpret
// the request, then restore the original path so that the OutputCache module
// can correctly process the response (if caching is enabled). string originalPath = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
HttpContext.Current.RewritePath(originalPath, false);
}
public static void RegisterRoutes(RouteCollection routes) {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute(
"Default", // Route name
"{controller}.aspx/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
// 原先是{controller}/{action}/{id} 给加了个后缀之后
// 之前的Default.aspx(默认的起始页)运行时就会报“传入的请求不与任何路由匹配。”
// 因为是在iis6下发布的 所以要加个后缀
// 也刚学这个不知道为什么会出现这问题 请问谁能帮忙看下?
} protected void Application_Start() {
RegisterRoutes(RouteTable.Routes);
}
}// 这是Default.aspx.cs里边默认的代码
public void Page_Load(object sender, System.EventArgs e) {
// Change the current path so that the Routing handler can correctly interpret
// the request, then restore the original path so that the OutputCache module
// can correctly process the response (if caching is enabled). string originalPath = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
HttpContext.Current.RewritePath(originalPath, false);
}
解决方案 »
- 关于Response.Redirect的问题
- 不同服务器上的数据库,表之间数据同步的问题或两个表联合查询
- 新手请教:类浏览器的问题(搜过以前的帖子了,没找到答案)
- 在DataGrid的编辑事件中如何获取在未编辑时的数据?
- 谁知道这个web service是怎么调用的?
- 邮件发送的问题?
- ms vs.net在设计视图中修改属性没有应用,有多少人遇到这个问题,可能是vs.net的一个bug
- 如何在javascript中调用一个外部可执行文件(如:cmd.exe)?
- 请问用C#怎样获得DATAGRID中某一格的TEXT(在线等)
- 为什么我用SqlDataAdapter生成的Update SQL是这样的?
- 关于一个XML的问题
- 求救(关于生成静态页面的问题)
加一个extension mapping就可以了
我这样直接加在{controller}后加上.aspx
http://localhost/MVCApp/Home.aspx/index 这个连接可以打开
http://localhost/MVCApp/Account.aspx/check/15 请求都可以但将 Default.aspx 设为起始页就不行了
直接在View里边设置起始页又不行...
是不是在 Default.aspx.cs 里边重写URL时的做法不正确?