问题描述
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禁止错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!