ASP.NET Passport SingOut 方法
2024-07-10 13:06:44
供稿:网友
,欢迎访问网页设计爱好者web开发。public static void signout(string strsignoutdotgiffilename)
{
httpcontext httpcontext = httpcontext.current;
string[] strs6 = new string[]{"mspauth", "mspprof", "mspconsent", "mspsecauth", "mspprofc"};
string[] strs1 = strs6;
strs6 = new string[]{"ticketdomain", "ticketdomain", "profiledomain", "securedomain", "ticketdomain"};
string[] strs2 = strs6;
strs6 = new string[]{"ticketpath", "ticketpath", "profilepath", "securepath", "ticketpath"};
string[] strs3 = strs6;
string[] strs4 = new string[5];
string[] strs5 = new string[5];
passportidentity passportidentity = null;
int i = 0;
httpcontext.response.clearheaders();
try
{
if (httpcontext.user.identity is passportidentity)
{
passportidentity = (passportidentity)httpcontext.user.identity;
}
else
{
passportidentity = new passportidentity();
}
if (passportidentity != null && _ipassportver >= 3)
{
for (i = 0; i < 5; i++)
{
object local1 = passportidentity.getcurrentconfig(strs2[i]);
if (local1 != null && local1 is string)
{
strs4[i] = (string)local1;
}
}
for (i = 0; i < 5; i++)
{
object local2 = passportidentity.getcurrentconfig(strs3[i]);
if (local2 != null && local2 is string)
{
strs5[i] = (string)local2;
}
}
}
}
catch (exception)
{
}
for (i = 0; i < 5; i++)
{
httpcookie httpcookie = new httpcookie(strs1[i], "");
httpcookie.expires = new datetime(1998, 1, 1);
if (strs4[i] != null && strs4[i].length > 0)
{
httpcookie.domain = strs4[i];
}
if (strs5[i] != null && strs5[i].length > 0)
{
httpcookie.path = strs5[i];
}
else
{
httpcookie.path = "/";
}
httpcontext.response.cookies.add(httpcookie);
}
httpcontext.response.expires = -1;
httpcontext.response.cache.setcacheability(httpcacheability.nocache);
httpcontext.response.appendheader("pragma", "no-cache");
httpcontext.response.contenttype = "image/gif";
httpcontext.response.writefile(strsignoutdotgiffilename);
string str = httpcontext.request.querystring["ru"];
if (str != null && str.length > 1)
{
httpcontext.response.redirect(str, false);
}
}