web.config虽然一直用,接触最多的也就是节点appSettings和connectionSettings,今天系统的梳理一下,了解一下webconfig各个节点的含义,先简单的浏览一下具体的webcofig,然后在介绍一些必要的知识。

<?xml version="1.0" encoding="utf-8"?>
<!--有时候webconfig中配置的节点较多,这时候可以将一些节点剥离出去单独写,然后引用,比如下面的<appSettings/>和<connectionStrings>
--> <!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301880
--> <!--configuraion是根节点,所有的配置内容都在configuration内进行-->
<configuration> <!--指定配置节和命名空间声明,配置节和配置节组定义在configSections-->
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections> <!--连接字符串设置-->
<connectionStrings configSource="connectionStrings.config" /> <!--appSettings是应用程序设置,可以定义应用程序的全局变量等信息-->
<appSettings configSource="appSettings.config" /> <!--控制ASP.NET运行时的行为-->
<system.web>
<!--identity控制应用程序的身份验证标识-->
<identity impersonate="true" userName="Administrator" password="" /> <!--通过 <authentication> 节可以配置 ASP.NET使用的安全身份验证模式,以标识传入的用户。Windows: 使用IIS验证方式,
Forms: 使用基于窗体的验证方式,Passport: 采用Passport cookie验证模式,None: 不采用任何验证方式
-->
<authentication mode="Forms">
<forms name="MVCDemo" cookieless="UseCookies" loginUrl="~/Account/Auth/Login" protection="All" timeout=""/>
<!--Name: 指定完成身份验证的Http cookie的名称。LoginUrl: 如果未通过验证或超时后重定向的页面URL,一般为登录页面,让用户重新登录。
Protection: 指定 cookie数据的保护方式,可设置为:All表示加密数据并进行有效性验证两种方式,None表示不保护Cookie,
Encryption表示对Cookie内容进行加密,validation表示对Cookie内容进行有效性验证。TimeOut: 指定Cookie的失效时间,超时后要重新登录。
-->
</authentication> <!--默认错误页设置.mode:具有On,Off,RemoteOnly 3种状态。On表示始终显示自定义的信息; Off表示始终显示详细的asp.net错误信息;
RemoteOnly表示只对不在本地Web服务器上运行的用户显示自定义信息。defaultRedirect:用于出现错误时重定向的URL地址-->
<customErrors defaultRedirect="Err.html" mode="RemoteOnly">
<!--特殊代码编号的错误从定向文件-->
<error statusCode="" redirect="NoAccess.htm" />
<error statusCode="" redirect="FileNotFound.htm" />
</customErrors>
<!-- 设置 compilation debug="true" 将调试符号插入已编译的页面中。但由于这会影响性能,因此只在开发过程中将此值设置为 true。
设置默认的开发语言C#。batch是否支持批处理-->
<compilation debug="true" defaultLanguage="c#" batch="false" targetFramework="4.5.2">
<assemblies>
<!--加的程序集引用,每添加一个程序集,就表示你的应用程序已经依赖了一个程序集,你就可以在你的应用程序中使用了-->
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies> <!--定义用于编译自定义资源文件的生成提供程序的集合。-->
<buildProviders>
<add extension=".aspx" type="System.Web.Compilation.PageBuildProvider"/>
</buildProviders>
</compilation>
<pages validateRequest="false" controlRenderingCompatibilityVersion="5.0" enableViewState="false" enableSessionState="false" enableEventValidation="false">
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages> <!--配置asp.net http运行库的设置。可以在计算机,站点,应用程序和子目录级别声明
允许最多的请求个数100,最长允许执行请求时间为80秒,控制用户上传文件的大小,默认是4M。
useFullyQualifiedRedirectUrl客户端重定向不需要被自动转换为完全限定格式。-->
<httpRuntime appRequestQueueLimit="" executionTimeout="" maxRequestLength="" useFullyQualifiedRedirectUrl="false" targetFramework="4.5.2" /> <!--httpModules在一个应用程序内配置 HTTP 模块。-->
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules> <!--为 Web 应用程序配置缓存设置。cache:定义全局应用程序缓存设置。outputCache :指定应用程序范围的输出缓存设置。
outputCacheSettings:指定可以应用于应用程序中页的输出缓存设置。sqlCacheDependency:为 ASP.NET 应用程序配置 SQL 缓存依赖项。-->
<caching>
<cache disableMemoryCollection = "false" disableExpiration = "false" privateBytesLimit = "" percentagePhysicalMemoryUsedLimit = "" privateBytesPollTime = "00:02:00"/>
<!--设计需要以这种方式缓存的页时,您需要向该页添加以下指令:<%@ OutputCache CacheProfile="ServerOnly" %>-->
<outputCacheSettings>
<outputCacheProfiles>
<add name="ServerOnly" duration="" varyByCustom="browser" location="Server" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>
<!--该节替换在 httpHandlers 和 httpModules 节中添加的与 AJAX 相关的 HTTP 处理程序和模块。
该节使 IIS 7.0 在集成模式下运行时可使用这些处理程序和模块。在iis7. 下运行 ASP.NET AJAX 需要 system.webServer 节。
对早期版本的 IIS 来说则不需要此节。-->
<system.webServer>
<modules>
<remove name="FormsAuthentication" />
<remove name="ApplicationInsightsWebTracking" />
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
</compilers>
</system.codedom>
</configuration>

  上边我们已经把具体的webconfig内容详细介绍了一遍,上边也说了,有时候webconfig中配置的节点较多,这时候可以将一些节点剥离出去单独写,然后引用,比如<appSettings/>和<connectionStrings>

  剥离出来的<appSettings/>文件如下:

  

  

<?xml version="1.0" encoding="utf-8"?>
<appSettings >
<!--RabbitMQ服务[Begin]-->
<add key="RabbitMQHostUri" value="tcp://127.0.0.1:20001/RabbitMQHost" />
<!--RabbitMQ服务[End]-->
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="WebSiteSqlServerDAL" value="MVC.DB.SqlServer.DAL" />
</appSettings>

  剥离出来的<connectionStrings>文件如下:

  

  

<?xml version="1.0" encoding="utf-8"?>
<connectionStrings>
<clear />
<add name="MvcDataConstr" connectionString="Server=.;Initial Catalog=MvcData;User ID=sa;Password=123" providerName="System.Data.SqlClient" />
</connectionStrings>

附张图吧,其实位置都无所闻,只要指定好就行

ASP.NET基础知识汇总之WebConfig各节点介绍的更多相关文章

  1. ASP.NET基础知识汇总之WebConfig自定义节点详细介绍

    之前介绍过Webconfig的具体知识ASP.NET基础知识汇总之WebConfig各节点介绍.今天准备封装一个ConfigHelper类,涉及到了自定义节点的东东,平时虽然一直用,但也没有系统的总结 ...

  2. Redis基础知识补充及持久化、备份介绍(二)--技术流ken

    Redis知识补充 在上一篇博客<Redis基础认识及常用命令使用(一)--技术流ken>中已经介绍了redis的一些基础知识,以及常用命令的使用,本篇博客将补充一些基础知识以及redis ...

  3. Windows_Program_Via_C_Translate_Win32编程的背景知识/基础知识_包括基本输入输出机制介绍

    Some Basic Background Story of The Win32 APIs Win32 API背景故事/背景知识 The Win32 application programming i ...

  4. Redis基础知识补充及持久化、备份介绍

    Redis知识补充 在上一篇博客<Redis基础认识及常用命令使用(一)–技术流ken>中已经介绍了redis的一些基础知识,以及常用命令的使用,本篇博客将补充一些基础知识以及redis持 ...

  5. 十四个关于ASP.NET基础知识问答(C#版)

    这是一些ASP.NET很基础的东西,希望对ASP.NET爱好者特别是刚刚入门的朋友有所帮助虽然示例代码是C#.NET,但是不影响VB.NET朋友的参考.好,继续往下看吧! 1.ASP.NET能在那些系 ...

  6. asp.net 基础知识

    1. DropDownList 的赋值 Response.Write(DropDownList1.Items.FindByText("潍坊").Value); Response.W ...

  7. ASP.NET-EF基础知识

    定义 asp.net Entity Framework是微软以ADO.NET为基础发展出来的对象关系对应(OR Mapping)解决方案.   三种EF工作模式(自己理解的) 从数据库表创建类 从类创 ...

  8. asp.netMVC4(基础知识----传值问题分析)

    (1)一般在数据交互的时候,都会涉及到前后台间的相互传值,一般的情况下,方法也有多种,下面就后台定义变量往前台传值: 以下是后台代码: /// <summary> /// 展示举报信息 / ...

  9. Asp.net基础知识

    1.[项目结构] 1.1文件后缀: .cs         源文件(程序代码) .csproj      项目文件(管理文件项) .sln         解决方案文件(管理项目) .config   ...

随机推荐

  1. Asp.Net Core中利用Seq组件展示结构化日志功能

    在一次.Net Core小项目的开发中,掌握的不够深入,对日志记录并没有好好利用,以至于一出现异常问题,都得跑动服务器上查看,那时一度怀疑自己肯定没学好,不然这一块日志不可能需要自己扒服务器日志来查看 ...

  2. centos7默认防火墙firewalld

    1.开关 启动: systemctl start firewalld 查看状态: systemctl status firewalld  停止: systemctl disable firewalld ...

  3. REST API设计指导——译自Microsoft REST API Guidelines(三)

    前面我们说了,如果API的设计更规范更合理,在很大程度上能够提高联调的效率,降低沟通成本.那么什么是好的API设计?这里我们不得不提到REST API. 关于REST API的书籍很多,但是完整完善实 ...

  4. .NetCore2.1 WebAPI 根据swagger.json自动生成客户端代码

    前言 上一篇博客中我们可以得知通过Swagger插件可以很方便的提供给接口开发者在线调试,但是实际上Swagger附带的功能还有很多, 比如使用NSwag生成客户端调用代码,进一步解放接口开发者. N ...

  5. Java面试系列--java基础

    Java基础总结 JAVA中的几种基本数据类型是什么,各自占用多少字节. 八大基本数据类型,byte:8位,short:16位,int:32位,long:64位,float:32位,double:64 ...

  6. SSH连接GitHub并配置ssh key

    SSH连接GitHub并配置ssh key 配置git的ssh提交,主要需要以下三步: 1.设置Git的user name和email 2.生成ssh 3.配置git 的ssh key 一.设置Git ...

  7. 跨站脚本攻击xss学习

    0.认识跨站脚本 举一个跨站脚本的简单例子. 假设一个页面将用户输入的参数直接显示到页面之中.(比如有如下代码) 在实际的浏览器中,在param中提交的参数正常会展示到页面之中.比如输入下面的URL: ...

  8. webpack4.0各个击破(6)—— Loader篇

    webpack作为前端最火的构建工具,是前端自动化工具链最重要的部分,使用门槛较高.本系列是笔者自己的学习记录,比较基础,希望通过问题 + 解决方式的模式,以前端构建中遇到的具体需求为出发点,学习we ...

  9. C#生成随机数的三种方法

    随机数的定义为:产生的所有数字毫无关系. 在实际应用中很多地方会用到随机数,比如需要生成唯一的订单号. 在C#中获取随机数有三种方法: 一.Random 类 Random类默认的无参构造函数可以根据当 ...

  10. Oracle day01 select where关键字

    select关键字 作用:检索“列” 注意:1.select后面的列可以起别名(查询的显示结果) 1) 列名后面一个空格后添加别名(别名中不许有“空格”) 2) 列名后面一个空格后使用双引号添加别名 ...