This project is read-only.

Sign out is not working.

Jan 12, 2014 at 7:02 PM
Hi Binod,

Sign out is not working, after click 'Sign out'. it still remains on Dashboard.
Jan 12, 2014 at 8:49 PM
Will have a look on this and let you know.
Jan 13, 2014 at 12:59 PM
Edited Jan 13, 2014 at 1:07 PM
Add the path too to the encrypted cookie in function MixERP.Net.BusinessLayer.Security.SignIn() and it will work temporarily:

HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedCookie);
cookie.Domain = FormsAuthentication.CookieDomain;
cookie.Path = ticket.CookiePath;
page.Response.Cookies.Add(cookie);

Another problem is that the cookie path which is set by the following statement in the MixERP.Net.BusinessLayer.Security.SignIn() function:

System.Web.Security.FormsAuthentication.RedirectFromLoginPage(userName, true, "MixERP.Net");

Besides redirect page to the main page, this statement will also override the previous encrypted FormsAuthenticationTicket which is supposed to be added to the cookie in the response buffer. Change it to the following statement:

page.Response.Redirect(FormsAuthentication.GetRedirectUrl(userName, remember));

This statement will not override the FormsAuthenticationTicket created in the code.
Jan 14, 2014 at 5:50 PM
Darius,

You are right. I am sorry that I did not carefully check the code when I committed the code in the past. You input is highly appreciated. You suggestion worked here although we might need to still re-factor the code in the future.

Thanks once again.
Jan 15, 2014 at 6:57 PM
Thanks Darius,

When I used FormsAuthentication.SetAuthCookie(userName, remember); , it worked too in place of below code.

HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedCookie);
cookie.Domain = FormsAuthentication.CookieDomain;
cookie.Path = ticket.CookiePath;
page.Response.Cookies.Add(cookie);

Please suggest, which code will be better?
Jan 17, 2014 at 12:34 AM
According to MSDN, FormsAuthentication.SetAuthCookie(userName, remember) method "creates an authentication ticket for the supplied user name and adds it to the cookies collection of the response, or to the URL if you are using cookieless authentication", and the simpler is FormsAuthentication.RedirectFromLoginPage() function which creates the cookie using the SetAuthCookie() method and redirect user to the default URL. In short, it wraps up several lines of code and makes us as developer easy to create a ticket.
Jan 18, 2014 at 11:01 AM
Thanks Darius.