如何在Windows 2003服务器中的MVC4应用程序中启用存储虚拟目录和存储控制器

时间:2013-10-16 13:02:40

标签: asp.net asp.net-mvc asp.net-mvc-4 iis asp.net-mvc-routing

使用IIS的Windows 2003服务器中的ASP.NET MVC4应用程序在虚拟目录存储中并且具有Store控制器,e.q url可以

http://mysite.com/store/Store/Details?product=C201S

此应用程序也需要从root用户访问,如

http://mysite.com/Store/Details?product=C201S

为此应用程序目录的副本已创建,并指向默认Web应用程序。 但是http://mysite.com/Store/Details?product=C201S会返回错误

The resource cannot be found. 
  Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

 Requested URL: /Store/Details


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272 

哪些脚趾不受影响链接商店控制器在网址中工作正常。 它看起来像商店应用程序和商店控制器名称冲突。如何解决这个问题?

global.asax.cs包含默认的rounting:

public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    //http://haacked.com/archive/2010/02/12/asp-net-mvc-2-optional-url-parameters.aspx
    routes.MapRoute(
        "Default", // Route name
        "{controller}/{action}/{id}", // URL with parameters
        new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
    );
}

1 个答案:

答案 0 :(得分:0)

根据我的评论,为了使两个Url工作,您应该将虚拟目录的父网站的主目录设置为与虚拟目录this page相同的目录,向您展示如何操作。