I had tried - RedirectToAction - Redirect - Url.Action
I'm creating an application form authentication using mvc4 empty project.
Here is code for login
[HttpPost]
[AllowAnonymous]
public ActionResult Index(UserModel user, string returnUrl)
{
try
{
string EmailAddress = user.EmailAddress;
string Password = user.Password;
if (!string.IsNullOrEmpty(EmailAddress) && !string.IsNullOrEmpty(Password) && EmailAddress == "admin@gmail.com" && Password == "admin123")
{
FormsAuthentication.SetAuthCookie(EmailAddress, true);
// Result = new { Status = "Success" };
FormsAuthentication.RedirectFromLoginPage(EmailAddress, true);
return Redirect(Url.Action("Index","Home"));
}
else
{
return RedirectToAction("Index");
}
}
catch (Exception)
{
// logging
throw;
}
}
}
My FilterConfig
public class FilterConfig
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
filters.Add(new AuthorizeAttribute());
}
}
I'm new to this section. I'm wondering why it is happening?
Screenshot of response after redirection to home page.