SessionExpire on Response.Redirect [英] SessionExpire on Response.Redirect

查看:62
本文介绍了SessionExpire on Response.Redirect的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我正在将文件从服务器下载到客户端计算机.下载完成后,我的会话将过期.
如何保持会话有效,直到用户注销.

这是我的下载代码:

Hi all

I''m downloading a file from the server to the client machine. When the download has been completed my session will have expired.
How do I keep my session alive until the user logs out.

This is my download code:

Response.Clear()
Response.ContentType = "application/x-zip-compressed"
Response.AppendHeader("Content-Disposition", "attachment; filename="; & ddlterritory.SelectedItem.Value + ".zip";)
Response.WriteFile(Server.MapPath("~/Backup/" + ddlterritory.SelectedItem.Value + ".zip"))

Response.Flush()
Response.Close()



任何帮助



any help

推荐答案

您可以在web.Config中增加会话超时的时间:
You could increase the length of the session time out in web.Config:
<system.web>
   <sessionState timeout="40" />
<system.web>

将其设置为40分钟.


如果要保持会话有效,除非不使用注销"事件,则可以在每次获取会话时滑动会话已到期.

只需在会话即将到期之前传达一个虚拟呼叫(如果需要)即可.您可以使用AJAX(XML HttpRequest)与服务器对话.

否则,如 OriginalGriff 所建议的那样,只需增加超时时间即可.
If you want to keep session alive unless ''logout'' event is not used then you can slide the session everytime it is about to get expired.

Just communicate a dummy call (if needed) before session is about to expire. You can use AJAX (XML HttpRequest) to talk to server.

Otherwise, as already suggested by OriginalGriff, just increase the timeout.


您好,所有

谢谢您的重播,我找到了解决方法

Response.Clear()
Response.ContentType =应用程序/x-zip压缩" Response.AppendHeader("Content-Disposition","attachment; filename =";& amp; ddlterritory.SelectedItem.Value +".zip";)Response.WriteFile( Server.MapPath(〜/Backup/" + ddlterritory.SelectedItem.Value +".zip"))
Response.Flush()
Response.Close()


问题是在上面的代码中插入了
Response.Close()
使用
Response.End()''此语句解决了我的问题



请把您的Floder(您正在其中创建要重新定向到客户端的excel文件)从根文件夹中移出
OF网站

因为如果您要尝试从其中删除某项,则假定存在asp.net引擎
主要尝试在compile/root文件夹中进行了更改,以使其尝试重新构成整个网站

因此,解决我的问题的最佳方法是将备份文件夹移出网站的根文件夹

及其工作
hii all

Thanks For your replay i got the solution

Response.Clear()
Response.ContentType = "application/x-zip-compressed" Response.AppendHeader("Content-Disposition", "attachment; filename="; &amp; ddlterritory.SelectedItem.Value + ".zip";) Response.WriteFile(Server.MapPath("~/Backup/" + ddlterritory.SelectedItem.Value + ".zip"))
Response.Flush()
Response.Close()


problem is that in the above code insted of
Response.Close()
Use
Response.End() ''This Statement solved my problem

OR

Please put your Floder(in which u are creating the excel file for redriecting to client ) Out of Root Folder
OF Web Site

Because if u are trying to delete someting from it then asp.net engine assumen there is
major changes happend in the compile /root folder for whith it try to complie againg the whole web site

So best solution on my problem is that i am moved my Backup Folder out OF Root Folder of web site

And Its Work


这篇关于SessionExpire on Response.Redirect的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆