English 中文(简体)
申述。 签字 未与海关合作
原标题:FormsAuthentication.SignOut Not Working With Custom-Domain Cookie

标题应当这样说。

Here s the code to set the cookie:

// snip - some other code to create custom ticket
var httpCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encodedTicket);
httpCookie.Domain = "mysite.com";
httpContextBase.Response.Cookies.Add(httpCookie);

我在此表示,我已签署网站:

FormsAuthentication.SignOut();

<>环境>:

  • ASP.NET MVC 3 Web Application

  • IIS 运货

  • Visual Studio 2010

  • Custom domain: "http://localhost.www.mysite.com"

因此,在尝试和清点时, co子仍然存在。 如果能够删除<代码>行(如违约为无效),则该行将处以罚款。

其它不容置疑的事情是,在确定域名时, Chrome的确在开发商工具的资源部分显示我的 co,但当idont设定域名时,它就是这样做的。

第二,当我实际与习俗领域建立 co时,根据下一个要求,在请求书(加密)中读到 co中时, co是存在的,但这个领域无效?

我也试图以同样的名义制造另一座 co子,并确定其有效期至昨天。 无.。

什么进展? 谁能帮助?

最佳回答

我认为,如果你将domain>vide on the forms elements in You web.config, to the same as the one in theirtom cookie,那么它就应当工作。 (EDIT:, 这种办法赢得t 工作,因为阿鲁特语种学法在你不喜欢的 co子上设定了其他旗帜,如。 HttpOnly <代码>SignOut 方法基本上只是将 co子的到期日期定在1999年,它需要确定合适的 co子。

如果你能够打硬图章,你可以推出自己的签字方法:

private static void SignOut()
{
    var myCookie = new HttpCookie(FormsAuthentication.FormsCookieName);
    myCookie.Domain = "mysite.com";
    myCookie.Expires = DateTime.Now.AddDays(-1d);
    HttpContext.Current.Response.Cookies.Add(myCookie);
}

认证书库仅仅是一个便衣;因此,你会以同样的方式将其撤销:,使其失效。

问题回答

我也存在同样的问题。 在我的案件中,我在AusthCookie储存了一些用户数据,并受到上述同样的影响,在每项请求的认证中,我阅读了 co,将用户数据输入一个静态变量。 在我的案件中,数据在应用中一直存在。 为了接下去,我必须首先明确我静态变量,然后结束 co。 我在我的主计长的LogOff方法中使用了以下方法:

AuthCookie.Clear(); //STATIC CLASS holding my userdata implemented by me.
Response.Cookies[FormsAuthentication.FormsCookieName].Expires = DateTime.Now.AddYears(-1);
Response.Cookies[FormsAuthentication.FormsCookieName].Value = null;
return RedirectToAction("Index", "Home");

希望这一帮助。

附录

在提交后,我用以下两条中线取代:

FormsAuthentication.SignOut();

... and it worked fine where it didn t before.

注:

AuthCookie.Clear();

......这并不影响奥思科,它只是对我写给违约值的静态类别。

同样,希望能做到这一点。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签