Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.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
Asp.net Http 500错误导致部署的MVC应用程序中出现空白页_Asp.net_Http - Fatal编程技术网

Asp.net Http 500错误导致部署的MVC应用程序中出现空白页

Asp.net Http 500错误导致部署的MVC应用程序中出现空白页,asp.net,http,Asp.net,Http,我这里有点问题。我有一个MVC应用程序,已部署到Windows Server 2008上的IIS 7。在Visual Studio 2012中,每当发生内部服务器错误(即http 500)时,它都会显示我为其设计的页面。但是,当我将其部署到IIS时,它会显示一个空白页面,这可能非常烦人,因为人们根本看不到应用程序的页面。所有我需要的是错误页来显示,而不是空白页,它目前作为部署的应用程序在客户端的网站上显示。然后,我可以在VisualStudio中修复错误。如果我违反了S.O.的任何规定,请原谅

我这里有点问题。我有一个MVC应用程序,已部署到Windows Server 2008上的IIS 7。在Visual Studio 2012中,每当发生内部服务器错误(即http 500)时,它都会显示我为其设计的页面。但是,当我将其部署到IIS时,它会显示一个空白页面,这可能非常烦人,因为人们根本看不到应用程序的页面。所有我需要的是错误页来显示,而不是空白页,它目前作为部署的应用程序在客户端的网站上显示。然后,我可以在VisualStudio中修复错误。如果我违反了S.O.的任何规定,请原谅

以下是我在ErrorController.cs中的设置

public ActionResult ForbiddenPage()
{ 
    Response.StatusCode = 403;
    Response.TrySkipIisCustomErrors = true; // add this line
    return View();
}
//
// GET: /Error/

public ActionResult PageNotFound()
{ 
    Response.StatusCode = 404;
    Response.TrySkipIisCustomErrors = true; // add this line
    return View();
}

//
// GET: /Error/

public ActionResult InternalServerError()
{ 
    Response.StatusCode = 500;
    Response.TrySkipIisCustomErrors = true; // add this line
    return View();
}
在web.config中,我得到的是:

<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
  <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." ...
</handlers>
<httpErrors errorMode="Custom" existingResponse="Replace">
  <remove statusCode="403" />
  <error statusCode="403" responseMode="ExecuteURL" path="/Error/ForbiddenPage" />
  <remove statusCode="404" />
  <error statusCode="404" responseMode="ExecuteURL" path="/Error/PageNotFound" />
  <remove statusCode="500" />
  <error statusCode="500" responseMode="ExecuteURL" path="/Error/InternalServerError"/>
</httpErrors>
</system.webServer>
应显示的视图如下所示:

@{
    ViewBag.Title = "Internal Server Error"; 
    Layout = "~/Views/Shared/_LayoutError.cshtml"; 
}

<h2></h2>

<div class="list-header clearfix">
    <span>Internal Server Error</span>
</div>
<div class="list-sfs-holder">
  <div class="alert alert-error">
    An unexpected error has occurred.... click<a href ="/Home/LogIn"><i><u>here</u></i>

</a> to login again..
  </div> 
</div>    
@{
ViewBag.Title=“内部服务器错误”;
Layout=“~/Views/Shared/\u LayoutError.cshtml”;
}
内部服务器错误
发生了意外错误。。。。单击以再次登录。。
如果我有什么东西可以帮助您提供解决方案,请在评论中告诉我。

是的,我找到了解决方案, 谢谢ppittle,你链接到Kev的答案有帮助。我尝试了答案中的建议,但在我的场景中没有效果。然而,Kev在回答中发布的链接帮助很大。工作的是生产服务器[IIS所在位置]中applicationHost.config中的设置

在以下位置查找名为applicationHost.config的文件: C:\Windows\System32\inetsrv\config

将下面的“overrideModeDefault”设置从Deny更改为Allow。


这就是我的工作。谢谢你

我也有同样的问题,但在任何地方都看不到这个答案:

运行我的应用程序的用户没有访问web.config中配置的数据库的权限。没有迹象表明这是我能找到的问题


我发现这是通过在DEBUG中部署而不是在Release中部署,然后显示了错误消息。

我认为IIS(在您的服务器上)与使用Visual Studio时的web.config设置不同。这看起来类似:
@{
    ViewBag.Title = "Internal Server Error"; 
    Layout = "~/Views/Shared/_LayoutError.cshtml"; 
}

<h2></h2>

<div class="list-header clearfix">
    <span>Internal Server Error</span>
</div>
<div class="list-sfs-holder">
  <div class="alert alert-error">
    An unexpected error has occurred.... click<a href ="/Home/LogIn"><i><u>here</u></i>

</a> to login again..
  </div> 
</div>