首页 文章

ASP.NET MVC URL路由或URL重写

提问于
浏览
1

我是ASP.NET MVC的新手,并试图确定以下任务的最佳方法 . 我有以下从Web窗体应用程序继承的URL,我希望通过在MVC中返回以下路径来继续运行:

我应该创建新的Map Route还是使用URL Rewrite模块?请提供您倡导的方法的示例 . 该应用程序托管在IIS 7.5中,并使用ASP.NET 4.5和MVC 4.0 .

1 回答

  • 1

    我也是新人,但我会尽力帮助你 .

    在App_Start / RouteConfig.cs中

    1

    routes.MapRoute(
       null,
       "Default.aspx",
       defaults: new { controller = "Default", action = "Index"},
    );
    

    2

    routes.MapRoute(
       null,
       "about.aspx",
       defaults: new { controller = "Default", action = "About"},
    );
    

    3

    routes.MapRoute(
       null,
       "{keyword1}-{keyword2}-contact.aspx",
       defaults: new { controller = "Default", action = "Contact"},
    );
    

相关问题