简体   繁体   中英

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

"server/ITEC"

I can't navigate to "server/ITEC/About" without the server returning an error - a 404 error.

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. 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?

How do I update my Global.asax file so that I can return the non-default controllers/actions? 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

"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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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