RedirectResult and RedirectToRouteResult not working inside OnActionExecuting if address specified as localhost(/Account/LogIn), if i specify url as http://google.com working properly.I wrote a BaseConfig class for administer session.That OnActionExecuting method while working redirect Login url if session is null.BaseConfig class that i used inside my project as follow;
public class BaseConfig : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
var context = HttpContext.Current;
if (context.Session["loggedUser"] == null)
{
filterContext.HttpContext.Response.Redirect(FormsAuthentication.LoginUrl);
//filterContext.Result = new RedirectToRouteResult(
//new RouteValueDictionary { { "controller", "Account" }, { "action", "LogIn" } });
}
base.OnActionExecuting(filterContext);
}
}
<authentication mode="Forms">
<forms loginUrl="~/Account/LogIn" defaultUrl="~/Home/Index" timeout="2880" protection="All" slidingExpiration="true" path="/"/>
</authentication>