ASP.Net 文件上传大小限制解决方案修改IIS7/7.5配置
IIS 7 默认文件上传大小时30M
要突破这个限制:
1. 修改IIS的applicationhost.config
打开 %windir%\system32\inetsrv\config\applicationhost.config
找到: <requestFiltering>节点,
这个节点默认没有 <requestLimits maxAllowedContentLength="上传大小的值(单位:byte)" /> 元素,IIS 7和IIS 7.5上测试过 最大值只能是<requestLimits maxAllowedContentLength="4294967295" /> <4GB,
为这个节点新增如下事例元素:<requestLimits maxAllowedContentLength="2147483647" /> ,上传的大小将改为2G
注意: %windir%\system32\inetsrv\config\applicationhost.config 文件一定不要用其他机器的文件替换,否则IIS将无法启动
此文件记录了,当前IIS中所有Site , App pool的信息,还有一些与机器相关的配置。
2 修改web.config
<system.web>
<httpRuntime executionTimeout="36000" maxRequestLength="2097151"/> <!--maxRequestLength:上传的大小,单位K ,executionTimeout:设置超时时间,单位:秒。(默认是90秒) -->
</system.web>
注意:这个maxRequestLength最大值只能是2097151K,设置大于这个值将会出现如下错误:
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: The value for the property 'maxRequestLength' is not valid. The error is: The value must be inside the range 0-2097151.
Source Error:
<httpHandlers />
<customErrors mode="RemoteOnly" />
<httpRuntime executionTimeout="36000" maxRequestLength="4194304" />
<authentication mode="Windows" />
<identity impersonate="true" />
3. web.config下如果有如下节点(此节点是为IIS 7设计的) ,则修改
<requestLimits maxAllowedContentLength="2147483647" /> 单位与applicationhost.config中的<requestLimits maxAllowedContentLength="2147483647" /&
相关文档:
//获取日期+时间
DateTime.Now.ToString(); // 2008-9-4 20:02:10
DateTime.Now.ToLocalTime().ToString(); // 2008-9-4 20:12:12
//获取日期
DateTime.Now.ToLongDateString().ToString(); // 2008年9月4日
D ......
//数字字符
public static string KeepNum(string str)
{
char[] tmp = new char[str.Length];
char[ ......
验证码页面后台Code.aspx.cs代码:(已经将验证码存于session中session["code"],可在调用页面直接读取session)
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebCon ......
问:为什么session在有些机器上偶尔会丢失?
答:可能和机器的环境有关系,比如:防火墙或者杀毒软件等,尝试关闭防火墙。
问:为什么当调用session.abandon时并没有激发session_end方法?
答:首先session_end方法只支持inproc(进程内的)类型的session。其次要激发session_en ......
我们在首次部署mvc的项目时通常会遇到一点问题。M$已经在Global.asax.cs文件中包含了这两句注释的提示。
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
但是我们访问这个网址看到上面的文章对iis5.1(win ......