I have a problem with my application ASP.Net MVC
, about authentication. Let's go by steps:
1) I have my login screen /Login/Index
simply the user logs, if found in the MySQL
database, and logs in and redirects to /Dashboard/Index
. This is the user verification code and if correct logs in:
[Note:] I use object SessionManager
Generic% and ISessionOperation
com with methods that Start
, Finish
, IsActive
, GetSessionId
, GetUsuario
.
Follow the code below the Action Login HttpPost
:
[HttpPost]
public ActionResult Logar(UsuarioDto Model, string Remind)
{
try
{
var UsuarioLogado = UsuarioDomain.Authentication(Model);
if (UsuarioLogado != null)
{
//--> Acesso
var AcessoDomain = new SmartAdmin.Domain.Acesso();
AcessoDomain.Save(GetUserInformation(String.Empty));
//--> Menus & Submenus
var CollectionMenuMain = new List<MenuModelView>();
foreach (var MenuMain in UsuarioDomain.GetAllowedMenus(UsuarioLogado.ID)) //--> Para cada menu pai pega os filhos e adiciona no modelo de visão
{
var CollectionSubMenus = UsuarioDomain.GetSubMenuFromMenu(MenuMain.ID);
var CurrentMenuMain = new MenuModelView() { Menu = MenuMain, CollectionSubMenu = CollectionSubMenus };
CollectionMenuMain.Add(CurrentMenuMain);
}
//--> Session
var Session = new SessionManager();
Session.Start(new UsuarioModelView() { Usuario = UsuarioLogado, CollectionMenusAndSubMenus = CollectionMenuMain });
return (RedirectToAction("Index", "Menu"));
}
else
{
TempData["Mensagem"] = "Usuário inexistente ou não esta ativo no sistema, contate o Administrador!";
return (RedirectToAction("Index", "Login"));
}
}
catch (Exception Ex)
{
throw new Exception(Ex.Message);
}
}
2) The second question is that I treat all Actions
of my application with ActionFilter
or I created a ActionFilter
that verifies if the session is active. If it is not redirected to /Login/Index
. If it is active the access to Action
calls, follow the example of my ActionFilter
that I use:
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
var Session = new SessionManager();
if (Session.IsActive() == false)
{
filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new
{
controller = "Login",
action = "Index"
}));
}
I use it this way in my Actions
within most% of% of my application, a common thing to use ok.
[AuthorizedUser]
public ActionResult Cedente()
{
var CedenteDomain = new Cedente();
var Model = CedenteDomain.GetItem(_ => _.ID == 1);
ViewBag.Mensagem = (TempData["Mensagem"] as String);
return View((Model==null)?new CedenteDto(): Model);
}
3) Let's go to the problem !, Next, this in development, location in my controllers
, and up to Visual Studio 2012
local configured
is working correctly parametrizei in IIS7
webconfig
to 60 also. But the bigger problem is that
when compile and put in my hosting domain and I try to log it properly but when I click on internal links
inside my application it redirects to the / Login / Index page I do not know why and recently clicked with the button
right click on an internal link and I had it open in new tab and it loaded correctly, the question is, when I click and click
in any menu ex:
Financial
- 1 - Tickets 2 - Assignor 3 - Cash
It redirects to Login / Index, but when I say open in new tab for Chrome for example it loads correctly, sometimes it redirects to sessionTimeOut
.
This does not all happen locally.
4) I was searching the internet and I saw that using Login/Index
is very bad tals in order I will not go into detail an alternative would be to use Cache but the objective question would be how to solve it.Details all my menu URLs are configured Session
I think it is properly correct.