下面我有我的Global.asax Session_Start
.NET会话状态已创建一个会话ID,但无法保存它,因为反应是由应用程序
string myBrowser = Utils.SafeUserAgent(Request);
foreach (string bannedbrowser in BrowserBan.BrowsersToBan)
{
if (myBrowser.IndexOf(bannedbrowser, StringComparison.OrdinalIgnoreCase) > -1)
{
HttpContext.Current.Response.Redirect("/bannedBrowser.htm");
Session.Abandon();
break;
}
已被清空它可以防止转码器访问啊,我的网站。但每一个现在,然后我得到一个错误说
System.Web.HttpException: Session state has created a session id, but cannot
save it because the response was already flushed by the application.
at System.Web.SessionState.SessionIDManager.SaveSessionID(
HttpContext context, String id, Boolean& redirected, Boolean& cookieAdded)
at System.Web.SessionState.SessionStateModule.CreateSessionId()
at System.Web.SessionState.SessionStateModule.DelayedGetSessionId()
at System.Web.SessionState.SessionStateModule.ReleaseStateGetSessionID()
at System.Web.SessionState.SessionStateModule.OnReleaseState(Object source,
EventArgs eventArgs)
at System.Web.SessionState.SessionStateModule.OnEndRequest(Object source,
EventArgs eventArgs)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web
.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously)
这只是发生时,我尝试通过(例如)谷歌转码器来访问它,但我想知道为什么它发生,我怎么能阻止它。
我必须放弃会话,以便刷新用户代理将重新评估。
顺便说一句:你好像有什么在做(防止某些浏览器访问一个网页)会在大多数情况下认为是不好的做法您可能依赖于客户端发送的User-Agent字符串,该字符串很容易被欺骗。如果您只是想警告用户有关潜在的不兼容问题,这将是合理的。但是从你使用的语言(“禁止浏览器”),我认为这不仅仅是一个不兼容的警告。 当然,你可能已经知道这一点,并有你的理由。只是想确保你牢记这些陷阱。 –
这是一个移动网站,有时来自谷歌搜索的用户通过谷歌的网页代码转换器来移除它,从而删除所有内容并杀死用户经验。 有些时候人们/成员使用gogole代码转换器。 – nLL
答案在这里:http://stackoverflow.com/questions/904952/whats-causing-session-state-has-created-a-session-id-but-cannot-save-it-becau/1966562#1966562 – Adi