Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 404在MVC中不是每次都处理页面_C#_Asp.net_Asp.net Mvc - Fatal编程技术网

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`操作的位置。可能重复