<httpRuntime>

1。在webconfig中httpconfig属性只能出现一次

配置httpRunTime也可以让FileUpload上传更大的文件,不过设置太大了会因用户将大量文件传递到该服务器而导致的拒绝服务攻击(属性有说明)
<httpRuntime>

<httpRuntime useFullyQualifiedRedirectUrl="true|false"

             maxRequestLength="size in kbytes"

             executionTimeout="seconds"

             minFreeThreads="number of threads"

             minFreeLocalRequestFreeThreads="number of threads"

             appRequestQueueLimit="number of requests"

             versionHeader="version string"/>

属性说明:

1.appRequestQueueLimit

    ASP.net将为应用程序排队的请求的最大数目。当没有足够的自由线程来处理请求时,将对请求进行排队。当队列超出了该设置中指定的限制时,将通过“503-服务器太忙”错误信息拒绝传入的请求。

2.executionTimeout

指示在被asp.net自动关闭前,允许执行请求的最大秒数

3.enable

指定是否在当前的节点及子节点级别启用应用程序域,默认值为True。

true---指定启动应用程序域

false---指定禁用应用程序域。应用程序将不会再内存中加载。

4.idleTimeOut

指定应用程序域在经过多长的空闲时间后将予以关闭。默认值为20分钟。

5.enableKernelModeCache

指定是否启用输出缓存。目前,该属性只有在安装IIS6.0版或更高版本后才起应用的作用。输出缓存的配置和请求的类型决定了是否对内容进行缓存。

若要对响应进行缓存,必须满足一下条件:

---必须通过页面指令或使用缓存API显示启用缓存。

---缓存必须具有过期策略,以便内核知道何时放弃缓存。

---缓存不能有任何变量标头或参数。

---请求不能要求进行任何身份验证。

true---指定启用缓存   false---指定禁用缓存

6.maxRequestLength

指示asp.net支持的最大文件上载大小。该限制可用于防止因用户大量文件传递到服务器而导致的拒绝服务器攻击。指定的大小以KB为单位。默认值为4096KB即4MB

7.minFreeLocalRequestFreeThreads

asp.net保持的允许执行新本地请求的自由线程的最小数目。该线程数目是为从本地主机传入的请求而保留的,以防某些请求在其处理期间发出对本地主机的子请求。这避免了可能的因递归重新进入web服务器而导致的死锁。

8.minFreeThreads

允许执行请求的自由线程的最小数目。asp.net为要求附加线程来完成处理的请求使这些线程保持自由状态。

9.userFullyQualifiedRedirectUrl

指示客户端重定向是否完全限定的(采用{ HYPELINK “http://server/path”}格式,这是某些移动控件所必需的),或者指示是否代之以将相对重定向发送到客户端。

true---指定客户端重定向需要以完全限定的格式发送。这是通过自动将不是完全限定的格式的所有重定向转换为完全限定的格式来实现的。

false----指定客户端重定向不需要被自动转换为完全限定格式。false是默认选项。

10.versionHeader

指定asp.net随每个响应所发送的版本头的值。Microsoft Visual Studio .Net只用该属性来确定当前使用的asp.net版本。这对产品环境来说不是必须的,并可可以通过Web.config或Machine.config移除该属性,或将该属性设置为空字符串(versionHeader=“”)来将其禁用。

 

   <httpRuntime requestValidationMode="2.0" /> 

validateRequest 这句我们知道是关闭验证,也就是说提交带标签,比如 <strong>粗体</strong> 这样的值时,ASP.NET 不会报错。

<?xml version="1.0" encoding="utf-8"?> <!-- 有关如何配置 ASP.NET 应用程序的详细信息,请访问 https://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration> <connectionStrings> <add name="DB-NetShopsConnectionString" connectionString="Data Source=.\MSSQLSERVER2012;Initial Catalog=DB-NetShops;User ID=sa;Password=your_password;Integrated Security=False" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <!-- 添加全局cookie设置 --> <httpCookies httpOnlyCookies="true" /> <compilation debug="true" targetFramework="4.7.2" /> <httpRuntime targetFramework="4.7.2" maxRequestLength="20480" executionTimeout="300" requestValidationMode="4.7.2" /> <!-- 移除httpOnlyCookies属性 --> <sessionState mode="InProc" timeout="20" /> <authentication mode="Forms"> <!-- 移除httpOnlyCookies属性 --> <forms loginUrl="~/WebForm1.aspx" defaultUrl="~/WebForm2.aspx" timeout="20" /> </authentication> <globalization culture="zh-CN" uiCulture="zh-CN" requestEncoding="utf-8" responseEncoding="utf-8" /> <customErrors mode="RemoteOnly" defaultRedirect="~/Error.aspx"> <error statusCode="404" redirect="~/404.aspx" /> <error statusCode="500" redirect="~/500.aspx" /> </customErrors> <pages masterPageFile="~/Site.master"> <controls> <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </controls> </pages> </system.web> <system.webServer> <httpProtocol> <customHeaders> <add name="X-Content-Type-Options" value="nosniff" /> <add name="X-Frame-Options" value="SAMEORIGIN" /> <add name="X-Xss-Protection" value="1; mode=block" /> </customHeaders> </httpProtocol> <staticContent> <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" /> </staticContent> <security> <requestFiltering> <requestLimits maxAllowedContentLength="20971520" /> </requestFiltering> </security> </system.webServer> <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" /> </compilers> </system.codedom> </configuration> 添加母版页代码设置,生成完整webconfig代码
最新发布
06-12
<configuration> <connectionStrings> <add name="DB-NetShopsConnectionString" connectionString="Data Source=.\MSSQLSERVER2012;Initial Catalog=DB-NetShops;User ID=sa;Password=your_password;Integrated Security=False" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <compilation debug="true" targetFramework="4.7.2" /> <httpRuntime targetFramework="4.7.2" maxRequestLength="20480" executionTimeout="300" requestValidationMode="4.7.2" /> <!-- 修正 sessionState 属性名 --> <sessionState mode="InProc" timeout="20" httpOnlyCookies="true" /> <!-- 正确:httpOnlyCookies(无多余s) --> <authentication mode="Forms"> <!-- 修正 forms 属性名 --> <forms loginUrl="~/WebForm1.aspx" defaultUrl="~/WebForm2.aspx" timeout="20" httpOnlyCookies="true" /> <!-- 正确:httpOnlyCookies(无多余s) --> </authentication> <globalization culture="zh-CN" uiCulture="zh-CN" requestEncoding="utf-8" responseEncoding="utf-8" /> <customErrors mode="RemoteOnly" defaultRedirect="~/Error.aspx"> <error statusCode="404" redirect="~/404.aspx" /> <error statusCode="500" redirect="~/500.aspx" /> </customErrors> </system.web> <system.webServer> <httpProtocol> <customHeaders> <add name="X-Content-Type-Options" value="nosniff" /> <add name="X-Frame-Options" value="SAMEORIGIN" /> <add name="X-Xss-Protection" value="1; mode=block" /> </customHeaders> </httpProtocol> <staticContent> <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" /> </staticContent> <security> <requestFiltering> <requestLimits maxAllowedContentLength="20971520" /> </requestFiltering> </security> </system.webServer> <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" /> </compilers> </system.codedom> </configuration> 报错不允许使用httpOnlyCookies特性
06-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值