I have an ASP.NET MVC application (version 6.0.0-rc1-final) with user roles and user stores. After some struggles, I was finally able to create a working input mechanism. However, I now have problems creating a clean logout. What is my exit code for the controller now looks like this:
public async Task<ActionResult> Logout() { if (User.Identity.IsAuthenticated) { await SignInManager.SignOutAsync(); } return RedirectToAction("Index", "App"); }
The problem with this code is that one cookie is not deleted: .AspNet.Microsoft.AspNet.Identity.Application
Until I delete the cookie manually, the application is in a dirty state and throws exceptions with a null pointer, because User.Identity is NULL.
I found an https://stackoverflow.com/a/3129648/212828/2000/2000/subscribe/questions/219828/... describing a similar scenario. But the solution is not suitable for me, because I am using MVC 6, which no longer has System.Web.
I also have a sample solution that just works great. In this solution, the mentioned cookie is never created. Perhaps the right solution is not to delete the cookie after logging out, but rather to prevent the creation of a cookie.
source share