MVC控制器被称为DocumentationController时,使用默认路由为我提供了403禁止错误 [英] MVC controller gives me a 403 forbidden error with the default route when it's called DocumentationController

查看:79
本文介绍了MVC控制器被称为DocumentationController时,使用默认路由为我提供了403禁止错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DocumentationController是否保留供系统使用?

Is DocumentationController reserved for system usage or something?

我创建了一个空白的MVC应用程序,并创建了带有相应视图的DocumentationController.如果我转到www.mysite.com/Documentation/Index,它会起作用,但是如果我转到www.mysite.com/Documentation/,那么我会被禁止使用403.

I created a blank MVC app, created a DocumentationController with corresponding view. It works if I go to www.mysite.com/Documentation/Index but if I go to www.mysite.com/Documentation/ then I get a 403 forbidden.

DocumentationController重命名为Documentation2Controller和关联的视图,它(默认路径等)完美运行.

Renaming DocumentationController to Documentation2Controller and associated views, it (the default route, etc.) works perfectly.

是保留关键字,还是有其他原因导致它没有选择默认路由?

Is it a reserved keyword or could there be another reason why it doesn't pick up the default route?

推荐答案

请确保您没有名为Documentation的实际虚拟/物理目录.

Make sure you don't have an actual virtual/physical directory named Documentation.

通过将RouteExistingFiles标志设置为true(在您的Routes配置中),您还可以指示MVC即使在与目录匹配的情况下也接管"该请求:

You can also instruct MVC to 'take over' the request even when it matches a directory by setting the RouteExistingFiles flag to true (in your Routes configuration):

public static void RegisterRoutes(RouteCollection routes)
{
    routes.RouteExistingFiles = true;

    //...
}

这篇关于MVC控制器被称为DocumentationController时,使用默认路由为我提供了403禁止错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆