Asp.net MVC 路由问题 403.14

Asp.net MVC Routing Issue 403.14

我的一个控制器无法加载 "Index"。例如:

 http://localhost:51638/Reserve/

work.but http://localhost:51638/Reserve/Index 行不通。 这个问题只针对我的一个控制器,另一个是正确的。 我的 RouteConfig 是:

public static void RegisterRoutes(RouteCollection routes)
        {


            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            // BotDetect requests must not be routed
            routes.IgnoreRoute("{*botdetect}",
              new { botdetect = @"(.*)BotDetectCaptcha\.ashx" });
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "UserHome", action = "Index", id = UrlParameter.Optional }
            );
        }

删除控制器并再次添加控制器后,它没有修复。 并遇到此错误页面:

HTTP 错误 403.14 - 禁止访问 Web 服务器配置为不列出此目录的内容。

这是我的控制器代码

public class ReserveController : Controller
{
    //
    // GET: /Reserve/
    public ActionResult Index()
    {
        return View();
    }
}

您可以添加另一个带有 "Reserve"

默认路由的路由
routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Reserve", action = "Index", id = UrlParameter.Optional }
            );

如果您有一个名为 ReserveController 的控制器和一个名为 Reserve 的目录,除非您提供完整路线。这就是您收到 403.14 错误的原因。

所以,更改控制器或目录的名称。