asp.net - 在调试和重建解决方案时维护会话? [英] asp.net - maintain session while debugging and rebuilding solution?
问题描述
会话[UserID]
中存储他们的 UserID
。 Web应用程序中的每一页都将检查一个有效的 Session [UserID]
。如果无效,则将用户重定向到登录屏幕。 这样做非常好,但是减慢了我在网站上调试每个页面的能力。每次我修改一个 *。cs
文件,我需要按F6来重建我的解决方案。这样做会破坏我的会话,这意味着我需要返回登录屏幕,输入我的用户名和密码,点击我正在开展的页面,做我的测试,对我的代码进行代码修改,然后重复。
有没有办法保持我的会话活着,每次我重新构建我的解决方案,所以我不必每次都去登录页面
不幸的是,我不知道你会发现任何方法来解决这个限制。每次构建项目时,都将触发重新启动Web应用程序。即使你要使用持久存储来保持会话,你将会丢失浏览器中设置的会话cookie。
你可以添加一个记住我功能到您的应用程序您需要进行一些重新实现,以便将数据存储中的当前用户身份验证信息与ASP.NET会话状态相比较不易挥发。此外,您可以将该信息存储在比会话cookie更持久的cookie中。
这是我能想到的最好的,或者至少是最好的我可以想到没有一些显着的扩展.NET安全提供程序。但是,用一粒盐 - 我从来没有试过解决这个特殊的问题,我几乎不认为自己是所有ASP.NET会话相关的专家。
I'm writing an asp.net Web Application. I wrote a login page that authenticates a user and stores their UserID
in the Session["UserID"]
. Every page in the web application will check for a valid Session["UserID"]
. If not valid, then redirect the user to the login screen.
This works great, but it's slowing down my ability to debug every page on my website. Each time I make a change to a *.cs
file, I need to press F6 to rebuild my solution. Doing this destroys my session, which means I need to go back to the login screen, type my username and password, click to the page I was working on, do my tests, make code changes to my code, and repeat.
Is there a way to keep my session alive everytime I re-build my solution so I don't have to go to the login page every single time?
Unfortunately, I don't know that you will find any way around this limitation. Every time you build your project, you are going to trigger a restart of the web application. Even if you were to use a persistent store for keeping sessions, you're going to lose the session cookie being set in your browser.
You could add a "remember me" feature to your app. You'd need to do a little reimplementation, in order to keep the information about the current user authentication in a data store that is less volatile than ASP.NET session state. Also, you'd store the index to that information in a cookie that is more persistent than a session cookie.
That's the best I can think of, or at least it's the best I can think of without some significant extensions to the .NET security providers. However, take it with a grain of salt -- I've never tried to solve this particular problem before, and I hardly consider myself an expert in all things ASP.NET session-related.
这篇关于asp.net - 在调试和重建解决方案时维护会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!