[英]MVC routing does not work for non-default/root action controller on virtual directory
I am using the default "ASP.NET MVC 2 Web Application" on IIS (which I have no admin access to) and while I can navigate to 我在IIS上使用默认的“ASP.NET MVC 2 Web应用程序”(我没有管理员访问权限),而我可以导航到
"server/ITEC" “服务器/ ITEC”
I can't navigate to "server/ITEC/About" without the server returning an error - a 404 error. 如果服务器没有返回错误,我无法导航到“server / ITEC / About” - 404错误。
I'm also using RouteDebugger for testing - when I use the default "server/ITEC" it matches (aka the default home/index controller action) but when I manually type in "server/ITEC/About" I don't even see the RouteDebugger page. 我也使用RouteDebugger进行测试 - 当我使用默认的“server / ITEC”时它匹配(也就是默认的home / index控制器动作)但是当我手动输入“server / ITEC / About”时我甚至看不到RouteDebugger页面。 Also, of note, when I place an "index.html" file in "server/Itec/About" it returns the results, which leads me to believe that the directory is configured to use the file system and not MVC routing when handling requests - is this a safe assumption? 另外值得注意的是,当我在“server / Itec / About”中放置一个“index.html”文件时,它返回结果,这使我相信目录配置为在处理请求时使用文件系统而不是MVC路由 - 这是一个安全的假设吗?
How do I update my Global.asax file so that I can return the non-default controllers/actions? 如何更新我的Global.asax文件以便我可以返回非默认控制器/操作? Or is this a server issue and how do I go about fixing that? 或者这是一个服务器问题,我该如何解决这个问题?
Thanks! 谢谢!
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);
}
}
}
I figured this out! 我想出来了!
On the Wildcard application maps section for aspnet_isapi.dll the checkbox for 在aspcard_isapi.dll的通配符应用程序映射部分的复选框
"Verify that file exists" was checked. 检查了“验证文件是否存在”。
Once I asked the System Administrator to uncheck it everything routed perfectly. 一旦我要求系统管理员取消选中,一切都完美无误。
Why is this even an option??? 为什么这甚至是一个选择? when would I use it? 我什么时候用它?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.