Asp.net mvc 如何将mvc路由重写为aspx
我有家庭控制器和索引操作方法。下面的url有效Asp.net mvc 如何将mvc路由重写为aspx,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,model-view-controller,Asp.net Mvc,Asp.net Mvc 3,Asp.net Mvc 4,Model View Controller,我有家庭控制器和索引操作方法。下面的url有效 http://localhost/home/index 有没有可能让它像下面这样工作 http://localhost/index.aspx 我正在Global.asax中尝试下面的代码,但不起作用 routes.MapPageRoute("MyPage", "create.aspx", "~/home/create"); 路由配置 public static void RegisterRoutes(RouteCollection route
http://localhost/home/index
有没有可能让它像下面这样工作
http://localhost/index.aspx
我正在Global.asax中尝试下面的代码,但不起作用
routes.MapPageRoute("MyPage", "create.aspx", "~/home/create");
路由配置
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapPageRoute("MyPage", "create.aspx", "~/home/create");
routes.MapRoute(
name: "Customized",
url: "{action}",
defaults: new { controller = "Home", action = "Default", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Reports",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Reports", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Default", id = UrlParameter.Optional }
);
}
您应该使用MapRoute()而不是MapPageRoute(),因为您仍然在引用MVC控制器/操作:
routes.MapRoute(
name: "Default2",
url: "index.aspx",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
PS:记住在其他可能最终干扰它的路由之前注册新路由。您应该使用MapRoute()而不是MapPageRoute(),因为您仍然在引用MVC控制器/操作:
routes.MapRoute(
name: "Default2",
url: "index.aspx",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
PS:记住在其他可能最终干扰它的路由之前注册新路由。您应该使用MapRoute()而不是MapPageRoute(),因为您仍然在引用MVC控制器/操作:
routes.MapRoute(
name: "Default2",
url: "index.aspx",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
PS:记住在其他可能最终干扰它的路由之前注册新路由。您应该使用MapRoute()而不是MapPageRoute(),因为您仍然在引用MVC控制器/操作:
routes.MapRoute(
name: "Default2",
url: "index.aspx",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
PS:记住在其他可能最终干扰它的路由之前注册新路由。您不能像现在这样对非静态内容进行MapPageRoute。如果您不想为您的路线隐藏
控制器
,定制的
已经这样做了。如果您正在混合使用MVC+WebForms,您应该参考本指南,了解如何配置路由
您不能像现在这样对非静态内容进行MapPageRoute。如果您不想为您的路线隐藏
控制器
,定制的
已经这样做了。如果您正在混合使用MVC+WebForms,您应该参考本指南,了解如何配置路由
您不能像现在这样对非静态内容进行MapPageRoute。如果您不想为您的路线隐藏
控制器
,定制的
已经这样做了。如果您正在混合使用MVC+WebForms,您应该参考本指南,了解如何配置路由
您不能像现在这样对非静态内容进行MapPageRoute。如果您不想为您的路线隐藏
控制器
,定制的
已经这样做了。如果您正在混合使用MVC+WebForms,您应该参考本指南,了解如何配置路由