|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
问题是他们究竟是喜欢他们是使用软件时,速度快还是速度慢好.(当然在3秒以内).无论是他们输入资料时,查找资料时,分析资料时.上传此次在项目中,用到了年夜文件上传,要上传的文件有100多m,因而研讨如今国际利用的年夜文件上传的
组件发明用的对照多的有两个控件AspnetUpload2.0和Lion.Web.UpLoadModule,别的另有思回在它的博客
堂中所说的举措http://blog.joycode.com/saucer/archive/2004/03/16/16225.aspx
两个控件的办法是:使用隐含的HttpWorkerRequest,用它的GetPreloadedEntityBody和ReadEntityBody办法从IIS为ASP.NET创建的pipe里分块读取数据。ChrisHynes为我们供应了如许的一个计划(用HttpModule),该计划除同意你上传年夜文件外,还能及时显现上传进度。
Lion.Web.UpLoadModule和AspnetUpload两个.NET组件都是使用的这个计划。
当上传单文件时,两个软件的办法是一样的,承继HttpModule
HttpApplicationapplication1=senderasHttpApplication;
HttpWorkerRequestrequest1=(HttpWorkerRequest)((IServiceProvider)HttpContext.Current).GetService(typeof(HttpWorkerRequest));
try
{
if(application1.Context.Request.ContentType.IndexOf("multipart/form-data")<=-1)
{
return;
}
//CheckTheHasEntityBody
if(!request1.HasEntityBody())
{
return;
}
intnum1=0;
TimeSpanspan1=DateTime.Now.Subtract(this.beginTime);
stringtext1=application1.Context.Request.ContentType.ToLower();
byte[]buffer1=Encoding.ASCII.GetBytes(("
--"+text1.Substring(text1.IndexOf("boundary=")+9)).ToCharArray());
intnum2=Convert.ToInt32(request1.GetKnownRequestHeader(11));
Progressprogress1=newProgress();
application1.Context.Items.Add("FileList",newHashtable());
byte[]buffer2=request1.GetPreloadedEntityBody();
num1+=buffer2.Length;
stringtext2=this.AnalysePreloadedEntityBody(buffer2,"UploadGUID");
if(text2!=string.Empty)
{
application1.Context.Items.Add("LionSky_UpLoadModule_UploadGUID",text2);
}
boolflag1=true;
if((num2>this.UpLoadFileLength())&&((0>span1.TotalHours)||(span1.TotalHours>3)))
{
flag1=false;
}
if((0>span1.TotalHours)||(span1.TotalHours>3))
{
flag1=false;
}
stringtext3=this.AnalysePreloadedEntityBody(buffer2,"UploadFolder");
ArrayListlist1=newArrayList();
RequestStreamstream1=newRequestStream(buffer2,buffer1,null,RequestStream.FileStatus.Close,RequestStream.ReadStatus.NoRead,text3,flag1,application1.Context,string.Empty);
list1.AddRange(stream1.ReadBody);
if(text2!=string.Empty)
{
progress1.FileLength=num2;
progress1.ReceivedLength=num1;
progress1.FileName=stream1.OriginalFileName;
progress1.FileCount=((Hashtable)application1.Context.Items["FileList"]).Count;
application1.Application["_UploadGUID_"+text2]=progress1;
}
if(!request1.IsEntireEntityBodyIsPreloaded())
{
byte[]buffer4;
ArrayListlist2;
intnum3=204800;
byte[]buffer3=newbyte[num3];
while((num2-num1)>=num3)
{
if(!application1.Context.Response.IsClientConnected)
{
this.ClearApplication(application1);
}
num3=request1.ReadEntityBody(buffer3,buffer3.Length);
num1+=num3;
list2=stream1.ContentBody;
if(list2.Count>0)
{
buffer4=newbyte[list2.Count+buffer3.Length];
list2.CopyTo(buffer4,0);
buffer3.CopyTo(buffer4,list2.Count);
stream1=newRequestStream(buffer4,buffer1,stream1.FileStream,stream1.FStatus,stream1.RStatus,text3,flag1,application1.Context,stream1.OriginalFileName);
}
else
{
stream1=newRequestStream(buffer3,buffer1,stream1.FileStream,stream1.FStatus,stream1.RStatus,text3,flag1,application1.Context,stream1.OriginalFileName);
}
list1.AddRange(stream1.ReadBody);
if(text2!=string.Empty)
{
progress1.ReceivedLength=num1;
progress1.FileName=stream1.OriginalFileName;
progress1.FileCount=((Hashtable)application1.Context.Items["FileList"]).Count;
application1.Application["_UploadGUID_"+text2]=progress1;
}
}
buffer3=newbyte[num2-num1];
if(!application1.Context.Response.IsClientConnected&&(stream1.FStatus==RequestStream.FileStatus.Open))
{
this.ClearApplication(application1);
}
num3=request1.ReadEntityBody(buffer3,buffer3.Length);
list2=stream1.Cont</p>asp可以轻松地实现对页面内容的动态控制,根据不同的浏览者,显示不同的页面内容。而浏览者一点觉察不出来,就像为他专门制作的页面一样。使用各种各样的组件,asp可以完成无比强大的功能。 |
|