程序化登录与.NET成员提供 [英] programmatic login with .net membership provider
本文介绍了程序化登录与.NET成员提供的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图单元测试一块code,需要一个当前登录的用户在测试中。使用.NET 2.0成员资格提供,我怎么能编程作为本次测试的用户身份登录?
解决方案
如果(Membership.ValidateUser(用户1,P @ ssw0rd))
{
FormsAuthentication.SetAuthCookie(用户1,真正的);
}
I'm trying to unit test a piece of code that needs a currently logged in user in the test. Using the .Net 2.0 Membership Provider, how can I programmatically log in as a user for this test?
解决方案
if(Membership.ValidateUser("user1",P@ssw0rd))
{
FormsAuthentication.SetAuthCookie("user1",true);
}
这篇关于程序化登录与.NET成员提供的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文