直接在ASP.net中上传大文件的方法.
方法一:在web.config中添加<httpRuntime maxRequestLength="100000" executionTimeout="45"/>
方法二:修改IIS配置文件windows->system32->inetsrv->metaBase.XML
方法三:
IServiceProvider provider = (IServiceProvider) HttpContext.Current;
HttpWorkerRequest wr = (HttpWorkerRequest) provider.GetService(typeof(HttpWorkerRequest));
byte[] bs = wr.GetPreloadedEntityBody();
....
if (!wr.IsEntireEntityBodyIsPreloaded())
{
int n = 1024;
byte[] bs2 = new byte[n];
while (wr.ReadEntityBody(bs2,n) >0)
{
.....
}
}
方法一:在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方法处理文件流上传代码
3.自定义Multipart MIME 解析器
自动截获MIME分割符
将文件分块写如临时文件
IServiceProvider provider = (IServiceProvider) HttpContext.Current;
HttpWorkerRequest wr = (HttpWorkerRequest) provider.GetService(typeof(HttpWorkerRequest));
byte[] bs = wr.GetPreloadedEntityBody();
....
if (!wr.IsEntireEntityBodyIsPreloaded())
{
int n = 1024;
byte[] bs2 = new byte[n];
while (wr.ReadEntityBody(bs2,n) >0)
{
.....
}
}