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



ASP.NET 使用 IIS 的 Windows 2003 服务器中的 MVC4 应用程序位于虚拟目录存储中,并具有存储控制器,例如 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 

脚趾不尾部的链接 url 中的存储控制器工作正常。它看起来像存储应用程序和存储控制器名称冲突。如何解决这个问题?

global.asax.cs 包含默认的漫游:

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
    );
}

根据我的评论,要使两个 URL 都正常工作,您应该将虚拟目录父网站的主目录设置为与本页向您展示如何操作的虚拟目录相同的目录。

最新更新