asp.net中上传大文件
直接在ASP.net中上传大文件的方法.
方法一:在web.config中添加<httpRuntime maxRequestLength="100000" executionTimeout="45"/>
方法二:修改IIS配置文件windows->system32->inetsrv->metaBase.XML
方法三:
1. httpHandler or HttpModule
a.在ASP.net进程处理request请求之前截获request对象
b.分块读取和写入数据
c.实时跟踪上传进度更新meta信息
2. 利用隐含的HttpWorkerRequest用它的GetPreloadedEntityBody 和 ReadEntityBody方法处理文件流
上传代码
HttpApplication application1 = sender as HttpApplication;
HttpWorkerRequest request1 = (HttpWorkerRequest) ((IServiceProvider) HttpContext.Current).GetService(typeof(HttpWorkerRequest));
try
{
if (application1.Context.Request.ContentType.IndexOf("multipart/form-data") <= -1)
{
return;
}
//Check The HasEntityBody
if (!request1.HasEntityBody())
{
return;
}
int num1 = 0;
TimeSpan span1 = DateTime.Now.Subtract(this.beginTime);
string text1 = application1.Context.Request.ContentType.ToLower();
byte[] buffer1 = Encoding.ASCII.GetBytes(("\r\n--" + text1.Substring(text1.IndexOf("boundary=") + 9)).ToCharArray());
int num2 = Convert.ToInt32(request1.GetKnownRequestHeader(11));
Progress progress1 = new Progress();
application1.Context.Items.Add("FileList", new Hashtable());
byte[] buffer2 = request1.GetPreloadedEntityBody();
num1 += buffer2.Length;
string text2 = this.AnalysePreloadedEntityBody(buffer2, "UploadGUID");
if (text2 != string.Empty)
{
application1.Context.Items.Add("LionSky_UpLoadModule_UploadGUID", text2);
}
bool flag1 = true;
if ((num2 > this.UpLoadFileLength()) && ((0 > span1.TotalHours) || (span1.TotalHours &g
相关文档:
What is ASP.NET
ASP.NET is a unified Web development model that includes the services necessary for you to build enterprise-class Web applications with a minimum of coding. ASP.NET is part of the .NET Framework, and when coding ASP.NET applications you have access to classes in the .NET Frame ......
//在当前页中关闭
Response.Write("<Script>window.opener.opener= null;window.opener.location.replace(window.opener.location.href='ideabank.aspx');window.close();</Script>");
//父类页打开 子页
Response.Write("<script>window.open('upideabank.aspx?id="+id+"','','height=50 ......
通常部属网站的时候需要编译那些需要的文件,和一些系统需要的组件。
会感觉到很繁琐。
发布网站是一个不错的选择:直接发布服务器上,设置好站点与端口即可。以下是总结的步骤。。。
第一、是将网站里所有的数据连接都做成从web.config中读取,这样的话,就可以一劳永逸了。
第二、就是IIS设置了,在IIS中的asp.net中 ......
ASP.NET 配置文件功能允许您存储简单(标量)值、集合和其他复杂类型,以及用户定义的类型。
1、属性定义信息
在配置文件中定义属性时,应指定将用于引用该属性的名称。例如,如果要存储邮政编码,则可以将属性命名为 PostalCode,然后可以获取属性值并将其设置为 Profile.Pos ......