我认为它可以工作。我们在我们的一个网站上做了#3。下面是我们用来处理它的一段代码。要使用此功能,请创建一个登录页面(transparentlogin.aspx或类似的页面),确保web.config文件允许匿名访问此页面,并在transparentlogin.aspx页面的page_load函数中输入如下代码:
const string specialpassword = "ThisIsOurSpecialPasswordForBehindTheScenesLogin";
if (MobileNumberFoundInHeader())
{
string username = GetMobileNumberFromHeaders();
System.Web.Security.FormsAuthentication.SetAuthCookie(username, false);
System.Web.Security.FormsAuthentication.Authenticate(username, specialpassword);
}
else
{
throw new Exception ("Mobile Number Missing");
}
然后,在MembershipProvider中的ValidateUser函数中,确保执行如下检查:
public override bool ValidateUser(string username, string password)
{
const string specialpassword = "ThisIsOurSpecialPasswordForBehindTheScenesLogin";
bool ValidationSuccess = false;
if (password == specialpassword)
{
ValidationSuccess = true;
}
if (DoStandardUsernamePasswordVerification() == true)
{
ValidationSuccess = true;
}
return ValidationSuccess;
}
提姆