Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 使用MVC模式替代MapPageRoute_Asp.net - Fatal编程技术网

Asp.net 使用MVC模式替代MapPageRoute

Asp.net 使用MVC模式替代MapPageRoute,asp.net,Asp.net,我想使用“web.com/software”或“web.com/about”访问我网站的一些页面,但我使用的是MVC模式和MapPageRoute方法(在RouteConfig.cs内部)仅适用于没有控制器的页面。 如果Home是我的控制器和视图中的软件,我希望使用“web.com/Software”而不是“web.com/Home/Software”进行访问。 是否可以使用ASP.NET或我需要在Web.config(IIS)和.htaccess(Apache)中使用重写 是否有理由使用Map

我想使用“web.com/software”或“web.com/about”访问我网站的一些页面,但我使用的是MVC模式和MapPageRoute方法(在RouteConfig.cs内部)仅适用于没有控制器的页面。 如果Home是我的控制器和视图中的软件,我希望使用“web.com/Software”而不是“web.com/Home/Software”进行访问。 是否可以使用ASP.NET或我需要在Web.config(IIS)和.htaccess(Apache)中使用重写


是否有理由使用MapPageRoute而不仅仅是MapRoute?使用或。已解决。谢谢。维克托:对不起,这就是我看到的例子。我已经回复了你的问题。您需要在专用答案框中发布解决方案,而不是将其编辑到问题中。专用答案框?这是什么?它在哪里?
namespace MyWebsite
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.MapPageRoute("SoftwarePage",
                "software", // web.com/software
                "~/Views/Home/Software");

            //routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

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