C# 404在MVC中不是每次都处理页面
有人能解释一下当我访问C# 404在MVC中不是每次都处理页面,c#,asp.net,asp.net-mvc,C#,Asp.net,Asp.net Mvc,有人能解释一下当我访问http://localhost:port/controler/blabla/blabla,但当我尝试访问http://localhost:port/controler/action/blabla/blabla,它不会调用我的自定义404页面,但会显示一个空白窗口 例如,当我调用http://localhost:port/Home/blabla/blabla,调用我的自定义页面;但是当我打电话给http://localhost:port/Home/Index/blabla/
http://localhost:port/controler/blabla/blabla
,但当我尝试访问http://localhost:port/controler/action/blabla/blabla
,它不会调用我的自定义404页面,但会显示一个空白窗口
例如,当我调用http://localhost:port/Home/blabla/blabla
,调用我的自定义页面;但是当我打电话给http://localhost:port/Home/Index/blabla/blabla< /代码>(添加动作的URL),它显示空白页。我的配置有问题吗
我的配置:
<customErrors mode="On" defaultRedirect="~/UnAuthorized/ErrorDefault/?error=1">
<error statusCode="404" redirect="~/UnAuthorized/ErrorResourceNotFound/?error=1"/>
<error statusCode="403" redirect="~/UnAuthorized/ErrorResourceNotFound/?error=1"/>
<error statusCode="500" redirect="~/UnAuthorized/ErrorDefault/?error=1"/>
</customErrors>
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1"/>
<remove statusCode="403" subStatusCode="-1"/>
<remove statusCode="500" subStatusCode="-1"/>
<error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="~/UnAuthorized/ErrorResourceNotFound/?error=1" responseMode="ExecuteURL" />
<error statusCode="403" subStatusCode="-1" path="~/UnAuthorized/ErrorResourceNotFound/?error=1" responseMode="ExecuteURL" />
<error statusCode="500" subStatusCode="-1" path="~/UnAuthorized/TestPage" responseMode="ExecuteURL" />
</httpErrors>
在自定义错误标记中使用重定向模式作为“ResponseDirect”,如
<customErrors mode="On" defaultRedirect="~/UnAuthorized/ErrorDefault/?error=1" redirectMode="ResponseRedirect">
<error statusCode="404" redirect="~/UnAuthorized/ErrorResourceNotFound/?error=1" />
<error statusCode="403" redirect="~/UnAuthorized/ErrorResourceNotFound/?error=1"/>
<error statusCode="500" redirect="~/UnAuthorized/ErrorDefault/?error=1"/>
</customErrors>
我想说http://localhost:port/Home/blabla/blabla
将尝试调用HomeController.blabla(blabla)
,其中blabla
操作不存在(因此重定向到404),并且http://localhost:port/Home/Index/blabla 将调用HomeController.Index(blabla),存在
Index`操作的位置。可能重复