I have this Action Method , And I use Authorize with Roles like as :
[HttpGet]
[Authorize(Roles = "member")]
public virtual ActionResult Profile()
{
...
}
And I have this Method For Login and add cooki:
SetAuthCookie(loginVM.UserName, RoleOfTheMember.Name, loginVM.RememberMe);
RoleOfTheMember.Name has value :"Member"
And this SetAutoCooki :
private void SetAuthCookie(string memberName, string roleofMember, bool presistantCookie)
{
var timeout = presistantCookie ? FormsAuthentication.Timeout.TotalMinutes : 30;
var now = DateTime.UtcNow.ToLocalTime();
var expirationTimeSapne = TimeSpan.FromMinutes(timeout);
var authTicket = new FormsAuthenticationTicket(
1,memberName,now,now.Add(expirationTimeSapne),presistantCookie,roleofMember,FormsAuthentication.FormsCookiePath
);
var encryptedTicket = FormsAuthentication.Encrypt(authTicket);
var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket)
{
HttpOnly = true,
Secure = FormsAuthentication.RequireSSL,
Path = FormsAuthentication.FormsCookiePath
};
if (FormsAuthentication.CookieDomain != null)
{
authCookie.Domain = FormsAuthentication.CookieDomain;
}
if (presistantCookie)
authCookie.Expires = DateTime.Now.AddMinutes(timeout);
Response.Cookies.Add(authCookie);
}
But when Call This Action I getting This ERROR By Browser :
The page isn't redirecting properly
Whats A problems ?
I don't use any RoleProvider . Do I use Implement Role Provider?