分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 技术分享

Web.config ?可配置的数据

发布时间:2023-09-06 01:17责任编辑:林大明关键词:Web配置

1.compilation:用来配置 ASP.NET 要编译 Web 应用程序。

1 <compilation debug="true" ?????????//是否调试2 ????optimizeCompilations="true" ???//是否重新编译 ??默认false3 ????targetFramework="4.0" /> ??????// 指定.NET Framework版本 
View Code

2.自定义错误

model : 指定是启用还是禁用自定义错误 ,mode="On|Off|RemoteOnly"  启用|禁用|默认值。

<customErrors mode="RemoteOnly" ????//是否启用和禁用 ???defaultRedirect="GenericErrorPage.htm"> ??//出错时将浏览器定向到的默认 URL ?<error statusCode="403" redirect="NoAccess.htm" />//403错误显示页面 ?<error statusCode="404" redirect="FileNotFound.htm" />//404错误显示页面</customErrors>
View Code

3.身份验证和角色

mode:指定应用程序的默认身份验证模式。 ?mode="[Windows|Forms|Passport|None]" ??window身份验证|窗体身份验证|默认身份验证|无需身份验证
<authentication mode="Windows"/>
View Code

4.system.webServer   只适用于 IIS 7.0 集成模式,而不适用于经典模式。具体而言,如果应用程序正在经典模式下运行,则会忽略 Web.config 文件的 system.WebServer 节中指定的所有托管代码模块和处理程序。与 IIS 的早期版本相同,托管代码模块和处理程序必须在 system.web 节的 httpModules 和 httpHandlers 元素中定义。

system.webServer 节的三个常见配置任务:

      1)  添加默认文件,以便在请求 URL 未包含特定的文件时,提供该默认文件。

<configuration> ?<system.webServer> ???<defaultDocument> ??????<files> ??????????<add value="Products.aspx" /> ????????</files> ???????</defaultDocument> ?</system.webServer></configuration> ????????????????
View Code

  2) 注册托管代码:每次请求时都会调用托管代码模块,通过该模块可对请求或响应进行自定义。

<configuration> ?<system.webServer> ???<modules> ?????<add name="CustomModule" type="Samples.CustomModule" ???????????precondition="managedHandler" /> ???</modules>//此前置条件会导致仅在请求 ASP.NET 应用程序资源(例如 .aspx 文件或托管处理程序)时才调用该模块。该资源中不包括静态文件(例如 .htm 文件)。 ???<defaultDocument> ?????<files> ???????<add value="Products.aspx" /> ?????</files> ???</defaultDocument> ?</system.webServer></configuration>
View Code

  3) 配置自定义响应标头

//实际的名称和类型将取决于该标头在应用程序中的功能。下面的示例演示如何添加名为 CustomHeader 且值为 CustomHeader 的自定义标头。<configuration> ?<system.webServer> ???<httpProtocol> ?????<customHeaders> ???????<add name="CustomHeader" value="CustomHeader" /> ?????<customHeaders> ???</httpProtocol> ?</system.webServer></configuration>
View Code

Web.config ?可配置的数据

原文地址:http://www.cnblogs.com/bkpengqing/p/7660047.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved