I want to show a certain section only if the user logged in. I have this set up as a Partial View.
@Html.Partial("ListPartial")
This part I can do by wrapping everything within that Partial View like this:
@if (User.Identity.IsAuthenticated) {
<h1>Stuff I want to show<h1>
}
When the user logs in, the code within the UserController looks like this:
return this.RedirectToAction<HomeController>(controller => controller.Index(uiUser));
So, what I want the “Stuff I want to show” is some User Accounts. This User Account information is accessed in the AccountController like this:
[HttpGet]
public ViewResult Accounts(Int64 userId)
{
var serviceAccounts = _accountManager.GetAccounts(userId);
var accounts = Mapper.Map<IEnumerable<ServiceModels.Account>,List<Models.AccountModel>>(serviceAccounts);
return View(accounts);
}
How can I get the Account information into the Partial View while still knowing if the User IsAuthenticated?
Call HtmlAction from within your partial if they are authenticated and pass it the parameters you need (or did I miss why you can’t use this?)