在开发过程中ASP.NET站点自动登录

编程入门 行业动态 更新时间:2024-10-27 01:25:47
本文介绍了在开发过程中ASP.NET站点自动登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

虽然开发一个ASP.NET网站,是一种方法来设置自动登录?

While developing an ASP.NET site, is the a way to setup automatic login?

例如,每一次我创建了这个网站,并运行它,我需要再次登录。我不想完全禁用安全性,但是我想在自动化当我工作时在网站上登录的过程。

For example, each time I build the site and run it, I have to login again. I don't want to disable security entirely, but I would like to automate the process of logging in while I'm working on the site.

推荐答案

只要保持你的浏览器中打开和 Ctrl + F5键后修改和/或在Visual Studio重新编译。这将保持身份验证Cookie。

Just keep your browser open and Ctrl+F5 after you modify and/or recompile in Visual Studio. This will keep the authentication cookie.

另一种可能性是设置一个自动的登录页面中,你会测试你是否在调试模式下,通过使用 FormsAuthentication.RedirectFromLoginPage(someusername,假)强制登录; 。然后,你可以指示Visual Studio中总是在这个网址运行网站:

Another possibility is to setup an automatic login page in which you would test whether you are in Debug mode and force a Login by using FormsAuthentication.RedirectFromLoginPage("someusername", false);. Then you could instruct Visual Studio to always run the web site at this url:

protected void Page_Load(object sender, EventArgs e) { #if DEBUG FormsAuthentication.RedirectFromLoginPage("someusername", false); #endif }

在理想情况下这个页面应该从构建过程中排除,从不发货。

Ideally this page should be excluded from the build process and never shipped.

作为由@Mufasa评论部分中指出,如果您的站点使用会话,你可能需要使用进程外模式(或的StateServer SqlServer的),而不是是InProc 的,因为当重新编译应用程序域将被重新加载并存储在内存中的一切丢失。

As pointed out in the comments section by @Mufasa if your site uses Session you might need to use out of process mode (StateServer or SqlServer) instead of InProc because when you recompile the application domain will be reloaded and everything stored in memory lost.

更多推荐

在开发过程中ASP.NET站点自动登录

本文发布于:2023-07-22 04:03:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1183985.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:过程中   自动登录   站点   NET   ASP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!