华赐软件 Bootstrap3

MVC错误处理(三)

Webconfig:

<!--"Off" 始终显示详细的 ASP.NET 错误信息-->
  <!--"On" 自定义的 ASP.NET 错误信息-->
  <system.web>
    <customErrors mode="On">
      <error statusCode="400" redirect="~/Error/Error400" />
      <error statusCode="404" redirect="~/Error/Error404" />
      <error statusCode="500" redirect="~/Error/Error500" />
    </customErrors>

Controller:

public class ErrorController : BaseController
    {
        //
        // GET: /Error/

        public ActionResult Index()
        {
            return View();
        }
        public ActionResult Error400()
        {
            return View();
        }
        public ActionResult Error404()
        {
            return View();
        }

        public ActionResult Error500()
        {
            return View();
        }

HTML:

@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <title></title>
     
    <style type="text/css">
        .PageDiv_404{width:500px;margin:0 auto;padding:50px 0 0 0;}
        .title_404 span{height:32px;line-height:32px;}
        .pic_404{display:inline-block;background:url(../images/WraningIco.png) no-repeat;width:32px;height:32px;margin-right:10px;}
        .cont_404{line-height:25px;padding-top:8px;}
    </style>
    <script type="text/javascript" src="@Url.Content("~/js/jquery-1.7.1.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/js/Language."+ViewBag.Lg+".js")"></script>
    <script type="text/javascript">
        $(function () {
            $("#Msg1").text(Language_Error_Error404_Msg);
            $("#Msg2").text(Language_Error_UrlWarning);
            $("#Msg3").text(Language_Error_EmailWarning); 
            $("#btnBack").val(Language_Common_btnBack);
        })
    </script>
</head>
<body>
<div class="PageDiv_404">
    <div class="title_404"> 
        <img src="../images/huawei_elab.png" />
    </div>
    <div class="cont_404">
        <div id="Msg1"></div>
        <div id="Msg2"></div>
        <div id="Msg3"></div>
    </div>
    <div style="padding-top:10px;">@*<a href="#" id="backHome">返回网站首页</a>*@
        <input id="btnBack" type="button" onclick="javascript:window.history.back();"/>
    </div>
    
</div>
</body>
</html>

 

posted @ 2013-02-28 10:18  OpenCsharp.Net  阅读(246)  评论(0编辑  收藏  举报
华赐软件 Bootstrap3
w.huacisoft.com">华赐软件 Bootstrap3