ASP.Net SQL Server会话管理 [英] ASP.Net SQL Server Session management

查看:89
本文介绍了ASP.Net SQL Server会话管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 您好 全部

am 体验 issue with 我的 托管 应用程序 投掷 身份验证 失败 异常此处 a code-leadattribute> background 问题:

我们的 应用程序 托管 2 服务器 加载 < span class =code-leadattribute> balancer
显然我们 manage session outside servers 我们 选择 SQL server to 执行 作业

我们的 超时 value set to 60 分钟但是如果 离开 my application in idle state for about 20 minutes 然后 点击 on a link 尝试 导航 另一个 page it register a < span class =code-leadattribute> 401
exception as 返回 to login page find fiddler 响应 在下面:

< span class =code-leadattribute> help me with some insight into 问题 scenario where a 会话 已清除 off SQL server timeout 间隔? 我在 会话 timeout field 显示 正确 数据

HTTP / 1. 1 401 未经授权
缓存控制: private
Content-Type: application / json; charset = utf-8
服务器: Microsoft-IIS / 7. 5
jsonerror: true
X-Powered-By : ASP NET
日期: 星期四 19 Jun 2014 07:00:55 GMT
内容长度: 105

{消息 身份验证失败。,StackTrace:null,ExceptionType:System.InvalidOperationException}
感谢

问候

Krishna Chaduvula

解决方案

假设您正在使用存储在SQL Server上的Session的默认实现。请检查相关会话超过其过期后,ASPStateTempSessions表中的条目是否已删除。如果未删除,则检查SQL Server代理是否正在运行。此过期机制已实现为存储过程/作业,DeleteExpiredSessions是负责使会话过期的SP。



通常我们在Web中配置会话状态.Config



 <   sessionstate  >  
mode =SQLServer
sqlConnectionString =data source = 127.0.0.1; user id = < 用户名 > ; password = < strongpassword >
cookieless =false
timeout =60
/>
< / strongpassword > < / username > < / sessionstate >


Hi All,

I am experiencing an issue with my hosted application that is throwing Authentication Failed Exception. Here is a background of the issue:

Our application is hosted on two servers with Load balancer in the front. Obviously, we had to manage the session outside the servers and we chose SQL server to do this job.

Our timeout value is set to 60 minutes. But, if I leave my application in idle state for about 20 minutes and then click on a link or try to navigate to another page, it registers a 401 exception as below and returns to the login page. Please find the fiddler response below:

Please help me with some insight into this issue. Can there be scenarios where a session is cleared off the SQL server before the timeout interval? I checked in the table for the session and the timeout field there is displaying correct data

HTTP/1.1 401 Unauthorized
Cache-Control: private
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.5
jsonerror: true
X-Powered-By: ASP.NET
Date: Thu, 19 Jun 2014 07:00:55 GMT
Content-Length: 105

{"Message":"Authentication failed.","StackTrace":null,"ExceptionType":"System.InvalidOperationException"}
Thank you.

Regards,

Krishna Chaduvula

解决方案

Assuming that you are using Default implementation of Session stored on SQL Server. Please check that the entries in the ASPStateTempSessions table are removed after the related sessions have exceeded their expiration. If it is not removed that check that SQL Server Agent is running or not. This expiration mechanism has been implemented as stored procedures/Jobs, DeleteExpiredSessions is the SP that is responsible for expiring the session.

Usually we configure session state in following way in Web.Config

<sessionstate>
            mode="SQLServer"
            sqlConnectionString="data source=127.0.0.1;user id=<username>;password=<strongpassword>"
            cookieless="false" 
            timeout="60" 
    />
	</strongpassword></username></sessionstate>


这篇关于ASP.Net SQL Server会话管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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