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. qt 拖拽 修改大小

    写次篇文章之前,qt窗口的放大缩小和拖拽我都是通过setGeometry方法实现的,但是作为windows程序,windows支持橡 皮筋式(拖拽时有一个虚框)拖拽和拉伸.通过setGeometry方 ...

  2. Python爬虫入门教程 10-100 图虫网多线程爬取

    图虫网-写在前面 经历了一顿噼里啪啦的操作之后,终于我把博客写到了第10篇,后面,慢慢的会涉及到更多的爬虫模块,有人问scrapy 啥时候开始用,这个我预计要在30篇以后了吧,后面的套路依旧慢节奏的, ...

  3. mybatis中resultMap配置细则

    resultMap算是mybatis映射器中最复杂的一个节点了,能够配置的属性较多,我们在mybatis映射器配置细则这篇博客中已经简单介绍过resultMap的配置了,当时我们介绍了resultMa ...

  4. 带着萌新看springboot源码09(springboot+JdbcTemplate)

    emmm.....常规开局,继续说一下废话,前面简单的说了一下spring的ioc容器创建原理(花了不少时间去看了别人的博客+查了不少资料+自己的理解),相信大家对ioc容器有了一个初步的认识了. s ...

  5. UML简单介绍-如何看懂UML(一)

      在计算复杂的数学题时,我们必然会打草稿计算 在绘画课中,我们可以素描出来看到的事物 那么在程序设计中呢? 如何描绘传达你脑海中的关于这个程序 ,设计的蓝图草稿?   OOP的程序设计中,最多的自然 ...

  6. 小程序开发笔记【一】,查询用户参与活动列表 left join on的用法

    今天在做一个用户活动查询功能的时候,查询参与的活动.正常,使用egg-mysql查询数据一般会这么写 result = await this.app.mysql.select('tb_activity ...

  7. 痞子衡嵌入式:第一本Git命令教程(5)- 提交(commit/format-patch/am)

    今天是Git系列课程第五课,上一课我们做了Git本地提交前的准备工作,今天痞子衡要讲的是Git本地提交操作. 当我们在仓库工作区下完成了文件增删改操作之后,并且使用git add将文件改动记录在暂存区 ...

  8. 深度学习(Deep Learning)资料大全(不断更新)

    Deep Learning(深度学习)学习笔记(不断更新): Deep Learning(深度学习)学习笔记之系列(一) 深度学习(Deep Learning)资料(不断更新):新增数据集,微信公众号 ...

  9. 对多字段进行去重 ( Linq 方式 )

    优质参考资料:http://www.cnblogs.com/A_ming/archive/2013/05/24/3097062.html

  10. Spring boot集成spring session实现session共享

    最近使用spring boot开发一个系统,nginx做负载均衡分发请求到多个tomcat,此时访问页面会把请求分发到不同的服务器,session是存在服务器端,如果首次访问被分发到A服务器,那么se ...