繁体   English   中英

MVC路由不适用于虚拟目录上的非默认/根操作控制器

[英]MVC routing does not work for non-default/root action controller on virtual directory

我在IIS上使用默认的“ASP.NET MVC 2 Web应用程序”(我没有管理员访问权限),而我可以导航到

“服务器/ ITEC”

如果服务器没有返回错误,我无法导航到“server / ITEC / About” - 404错误。

我也使用RouteDebugger进行测试 - 当我使用默认的“server / ITEC”时它匹配(也就是默认的home / index控制器动作)但是当我手动输入“server / ITEC / About”时我甚至看不到RouteDebugger页面。 另外值得注意的是,当我在“server / Itec / About”中放置一个“index.html”文件时,它返回结果,这使我相信目录配置为在处理请求时使用文件系统而不是MVC路由 - 这是一个安全的假设吗?

如何更新我的Global.asax文件以便我可以返回非默认控制器/操作? 或者这是一个服务器问题,我该如何解决这个问题?

谢谢!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace mikeProg
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode,
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");           

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults            
            );

            RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);

        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
        }
    }
}

我想出来了!

在aspcard_isapi.dll的通配符应用程序映射部分的复选框

检查了“验证文件是否存在”。

一旦我要求系统管理员取消选中,一切都完美无误。

为什么这甚至是一个选择? 我什么时候用它?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM