0
これは、いくつかのアクションでのasp.net MVC 5. についての質問ユーザが許可されているが、彼のIDを介してユーザを取得した後、それはユーザーことを確認する!= nullの場合。なぜ彼らはuser!= nullをチェックしますか?ユーザが許可されるが、ユーザーをチェック!= nullを
[Authorize, /* with some other attributes */]
public async Task<ActionResult> ChangePassword(ChangePasswordViewModel model)
{
// ...
var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
// why they check user != null?
if (user != null)
{
await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
}
}