前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >.net自定义错误页面实现

.net自定义错误页面实现

作者头像
小小许
发布于 2018-09-20 09:12:01
发布于 2018-09-20 09:12:01
1.3K00
代码可运行
举报
文章被收录于专栏:angularejs学习篇angularejs学习篇
运行总次数:0
代码可运行

前言:

  在实际的web开发中,经常会遇到以下情况,导致给用不好的体验:     a、程序未处理的异常,直接输出显示到用户页面     b、用户访问的资源不存在,直接显示系统默认的404页面     c、其它以下请求错误状态的系统默认页面(403等)   为了给用户友好的体验,在实际项目开发中, 需要对系统会不同的异常定制相应的友好提示页面

  .net中自定义异常页面的重定向都是通过web.config配置页面配置实现, 其具体的实现方式有两种方式:

其一、通过节点system.web新增customErrors配置节点实现

IIS环境需求:IIS7、IIS7+、IIS7以前版本

作用对象:作用于Asp.Net级别的错误处理程序        也就是说,对于(.html/.js)等静态资源不起作用 实现方式:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
 <system.web>
   <customErrors mode="On" defaultRedirect="ApplicationErroy.aspx">
      <error statusCode="403" redirect="/ErrorPage/403.html"/>
      <error statusCode="404" redirect="/ErrorPage/404.html"/>
      <error statusCode="500" redirect="/ErrorPage/500.html"/>
    </customErrors>
  </system.web>

其二、通过节点system.webServer新增httpErrors配置节点实现

 IIS环境需求:IIS7、IIS7+

作用对象:作用于IIS级别的错误信息处理程序        也就是说,asp.net程序异常和静态资源异常都处理 实现方式:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
  <system.webServer>
    <httpErrors errorMode="Custom" existingResponse="Replace">
      <clear />
      <error statusCode="404" responseMode="ExecuteURL" path="/ErrorPage/404.html" />
      <error statusCode="403" responseMode="ExecuteURL" path="/ErrorPage/403.html" />
      <error statusCode="500" responseMode="Redirect" path="/ErrorPage/500.html" />
    </httpErrors>
  </system.webServer>

应用总结:

  通过上面的描述,在实际开发中,只要环境时IIS7+,那么完全采用第二种方式即可

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018-05-10 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
VS.Net 2005 Design-Time Integration
Introduction This article provides an overview of the VS.NET 2005 Design-Time Integration Support. The article highlights the .NET design-time architecture and discusses the design-time attributes and the various design-time components in details with ref
张善友
2018/01/29
5940
VsxHowTo -- 把Windows Forms Designer作为自己的编辑器(2)
我们在上一篇文章里利用Windows Forms Designer做了一个简单的表单设计器,但这个设计器还存在一些问题,比如控件不能自动命名;文档窗口不会自动加入dirty标记;不能undo/redo和copy/paste;不能保存和读取数据等等。这一篇我们来逐一解决这些问题。
明年我18
2019/09/18
4250
从Component对象到CodeDom——舞动你的Code系列(1)
我们经常会有这样的需求或者想法:动态的生成或者修改代码。当然,我们可以把代码看成字符串而直接修改,但是这种做法也未免太生硬了,能解决的问题有限;而另一个方式就是CodeDom。 CodeDom是强大的!我们感谢微软,给我们提供了强大的描述面向对象语言的框架;我们感谢微软,给我们提供了能够根据CodeDom生成代码或者程序集的CodeDomProvider;可惜微软没有给我们提供能够从object或者代码生成CodeDom的能力。 关于CodeDom的知识本文不过多涉及、感兴趣的童鞋可以阅读MSDN或者博客园
葡萄城控件
2018/01/10
7470
【Tomcat】《How Tomcat Works》英文版GPT翻译(第十四章)
In previous chapters you have seen how you can have a servlet container by instantiating a connector and a container and then associating them with each other. Only one connector could be used, and that was to serve HTTP requests on port 8080. You could not add another connector to service HTTPS requests, for example.
阿东
2024/01/23
1040
【Tomcat】《How Tomcat Works》英文版GPT翻译(第十四章)
.NET 基金会项目介绍-Windows Phone Toolkit
Windows Phone Toolkit 是属于 .Net 基金会的一个项目,本文将简要介绍该项目相关的信息。
newbe36524
2020/03/16
3780
CTK 插件框架介绍
The CTK Plugin Framework can shortly be described as a dynamic component system for C++.
全栈程序员站长
2022/09/05
1.1K0
Top JavaScript Frameworks for Web Application Development
JavaScript is a multi-worldview language. It underpins occasion driven, utilitarian, and basic programming styles. JavaScript viewed as the language of the web for conventional customer side use, yet it is additionally now being utilized for server-side applications alongside local versatile application development, work area applications, machine learning for automation, progressive web apps.
用户4822892
2019/07/19
6230
Top JavaScript Frameworks for Web Application Development
Working with Windows Workflow Foundation in ASP.NET
September of 2005, Microsoft unleashed Windows Workflow Foundation (Windows WF) at its semi-annual Professional Developer's Conference. As one of the pillars of the WinFX APIs, Windows WF provides developers with a common framework on which to develop proc
张善友
2018/01/29
1K0
【Tomcat】《How Tomcat Works》英文版GPT翻译(序章)
This book dissects Tomcat 4.1.12 and 5.0.18 and explains the internal workings of its free, open source, and most popular servlet container code-named Catalina.
阿东
2023/12/06
2060
【Tomcat】《How Tomcat Works》英文版GPT翻译(第五章)
A container is a module that processes the requests for a servlet and populates the response objects for web clients. A container is represented by the org.apache.catalina.Container interface and there are four types of containers: Engine, Host, Context, and Wrapper. This chapter covers Context and Wrapper and leaves Engine and Host to Chapter 13. This chapter starts with the discussion of the Container interface, followed by the pipelining mechanism in a container. It then looks at the Wrapper and Context interfaces. Two applications conclude this chapter by presenting a simple wrapper and a simple context respectively.
阿东
2024/01/10
2170
【Tomcat】《How Tomcat Works》英文版GPT翻译(第五章)
The RoadMap for Java Developers in 2020
The 2020 Java Developer Roadmap is comprised of long stretches of understanding and furthermore a portion of the unhampered ways about how you ought to turn into the Java master. This guide will absolutely assist you in answering different such consumi
用户4822892
2020/03/03
9180
Take Zero-Touch Approach Lock Down IoT Device 采用零接触方式锁定物联网设备
The demonstrated ability of hackers to penetrate IoT devices says more about the level of security of these devices than the skill of the hackers: in most cases, the affected products lack the most basic security provisions. That said, basic security is simple conceptually, but its implementation requires careful attention at every node in a system to avoid vulnerabilities.
银河1号
2019/05/16
7450
Take Zero-Touch Approach Lock Down IoT Device 采用零接触方式锁定物联网设备
Features of .Net Development Platform
.Net Framework has been probably the best advancement by Microsoft for web applications, work area applications and site improvement. .Net designers and individuals who have been in steady interface with this stage definitely realize that it has its own library of dialects, structure and further turns of events. Novices and entrepreneurs should realize that from a straightforward design, .Net system has advanced to a total environment offering help and improvement procedures for a wide range of uses
saurabhkumawat
2021/02/24
3700
Features of .Net Development Platform
Weex 中别具匠心的 JS Framework
为了达到所有页面在用户端达到秒开,也就是网络(JS Bundle下载)和首屏渲染(展现在用户第一屏的渲染时间)时间和小于1s。
一缕殇流化隐半边冰霜
2018/08/29
7.4K0
Weex 中别具匠心的 JS Framework
VsxHowTo -- 把Windows Forms Designer作为自己的编辑器(3)
在前两篇里,我向大家介绍了如何把vs的windows forms designer作为自己的自定义编辑器,这这篇文章里我再介绍一些大家可能关心的和设计器相关的其他问题。
明年我18
2019/09/18
8300
VsxHowTo -- 把Windows Forms Designer作为自己的编辑器(3)
(收藏)搭建.NET Framework 3.0开发环境 及SharePoint 2007/WSS 3环境
第一步:首先您必须安装.NET Framework 3.0,则可以下载其Redistributable Package Microsoft .NET Framework 3.0 Redistributable Package  第二步:Microsoft® Windows® Software Development Kit for Windows Vista™ and .NET Framework 3.0 Runtime Components正式版 这是.NET 3.0程序开发的运行库,里面有你开发WPF、
用户1172164
2018/01/16
1.6K0
用.NET创建Windows服务
译者说明:我是通过翻译来学习C#的,文中涉及到的有Visual Studio.NET有关操作,我都根据中文版的VS.NET显示信息来处理的,可以让大家不致有误解。
Java架构师必看
2021/03/22
1.1K0
实现类似“添加扩展程序…”的设计时支持
Ajax Control Toolkit这个控件库内包含一些扩展控件,利用这些扩展控件,可以非常方便的为普通的控件添加Ajax效果,例如,利用AutoCompleteExtender控件,可以为文本框添加自动完成的ajax效果。当然,这并不是本文想讨论的内容。
明年我18
2019/09/18
5170
.NET牛人应该知道些什么,我的回答
What Great .NET Developers Ought To Know (More .NET Interview Questions)
深蓝studyzy
2022/06/16
4250
Silverlight第三方控件专题
这里我收集整理了目前网上silverlight第三方控件的专题,若果有所遗漏请告知我一下。 名称 简介 截图 telerik 商 RadControls for Silverlight includes 24 UI controls that can be used in pure Silverlight applications or as parts of existing ASP.NET applications. Sharing the same codebase with o
用户1172164
2018/03/01
1.1K0
推荐阅读
相关推荐
VS.Net 2005 Design-Time Integration
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文