我有一个错误页面,其布局在大多数情况下都可以正常工作,但是当返回部分视图的控制器中出现错误时,错误页面及其布局被放置在部分视图中。我想这是合乎逻辑的,但我希望将错误页面作为整页加载。如何在不更改所有错误处理的情况下实现这一点。
网络配置:
<customErrors mode="On" defaultRedirect="~/Error">
<error statusCode="500" redirect="~/SystemPages/ErrorPage" />
<error statusCode="403" redirect="~/SystemPages/FileNotFound" />
<error statusCode="404" redirect="~/SystemPages/FileNotFound" />
</customErrors>
全球.asax:
Shared Sub RegisterGlobalFilters(ByVal filters As GlobalFilterCollection)
filters.Add(New HandleErrorAttribute())
End Sub
基础控制器:
Protected Overrides Sub OnException(ByVal filterContext As ExceptionContext)
If filterContext Is Nothing Then Return
If TypeOf (filterContext.Exception) Is FaultException Then
Dim CodeName As String =
CType(filterContext.Exception, FaultException).Code.Name
Dim Message As String = CType(filterContext.Exception, FaultException).Message
TempData("ErrorMessage") = Message
Else
Logging.LogDebugData(HamtaDebugInformation(filterContext.RouteData))
Logging.WriteExceptionLog(filterContext.Exception)
TempData("ErrorMessage") = filterContext.Exception.Message
End If
Response.Redirect("/SystemPages/ErrorPage")
End Sub
搜索控制器:
Function GetData() As ActionResult
...
Return PartialView("_Tab", vmData)
错误页面:
@Code
ViewData("Title") = "ErrorPage"
Layout = "~/Views/Shared/_Layout.vbhtml"
End Code
<div id="mainContent" class="oneColumn">
<div class="panel">
<span class="panelTLC"></span>
<span class="panelTRC"></span>
<div id="inputPanel" class="panelContent">
<div class="modul">
<div class="modulHead">
<span class="TLC"></span>
<span class="TRC"></span>
</div>
<div class="modulContent">
<span class="TLC"></span><span class="TRC"></span>
<p>@ViewBag.ErrorMessage</p>
<p>@TempData("ErrorMessage")</p>
<span class="BLC"></span>
<span class="BRC"></span>
</div>
</div>
</div>
<span class="panelBLC"></span><span class="panelBRC"></span>
</div>
</div>