0

我希望来自 localhost/Other_Data 的所有请求都移动到 localhost/Other_Data/index2?id_Mode=1&city="ddd" 但我不喜欢使用重定向我想使用路由可能对我有帮助...谢谢

public class SupperController: Controller
{

    public virtual ActionResult Index()
    {
...
    } 
}

public class Other_Data:SupperController
{

    public ActionResult Index2(int Id_Mode, string city)
    {
....
..
    } 
}

....
..
.
        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );

        routes.MapRoute(
            name: "Default1",
            url: "Other_Data/",
            defaults: new { controller = "Other_Data", action = "Index2", Id_Mode = 1, city="ddd"}
        );
4

1 回答 1

0

尝试这个

routes.MapRoute("Other_Data" , "Other_Data/index2/{id_Mode}/{city}" , 
 new { controller = "Other_Data", action = "index2",id_Mode=1,city="ddd" });
于 2013-10-08T09:12:38.757 回答