ASP.NET MVC4 アプリを開発しています。ユーザー固有の詳細を取得するには、ログイン 2 ストアド プロシージャの後に呼び出す必要があります。このようなことを行うログイン コントローラーがあります。
[HttpPost]
public ActionResult Login(UserLogin user)
{
if (ModelState.IsValid)
{
bool res = System.Web.Security.Membership.ValidateUser(user.UserName, user.Password);
if (res)
{
Utente utente = commonRepository.GetProfiloUtente(user.UserName);
if (utente != null)
{
Session["utente"] = utente;
}
DateTime dataLavorativa = commonRepository.GetGiornoLavorativoPrecedente(utente.IDInterno);
Session["data_lavorativa"] = dataLavorativa;
FormsAuthentication.SetAuthCookie(user.UserName, user.RememberMe);
return RedirectToAction("Index", "Home");
}
else
{
ModelState.AddModelError("", "Login data is incorrect!");
}
}
return View("Index", user);
}
これは、ユーザーが認証されておらず、ログインページから強制的に渡された場合に機能します...
ユーザーがアプリに接続したが、既に認証されている場合にこれらのメソッドを呼び出すには、コードをどこに配置すればよいですか?
これを各コントローラーの各インデックスアクションに入れることはできません...ありがとう