Reputation: 11448
I wish to show a different View form my Action method to an Admin and User:
public ActionResult Create()
{
CreateIssue issue = new CreateIssue();
if (user.SupportAdmin)
{
return View("Admin/Create", issue);
}
return View(issue);
}
Then my Views look like this:
@model myApp.Models.CreateIssue
@{
ViewBag.Title = "IT HelpDesk - Create a new Issue";
}
@Html.Partial("_Create")
I have put the content inside a Partial called _Create
as most of the content is the same, but I want to add an additional input to the Admin view which will sit in the middle of my _Create
partial view. I'm not sure how to go about this, I did try to render a section
in my Admin create view which is called inside the partial but they're only allowed on the _Layout
page I think?
Upvotes: 0
Views: 621
Reputation: 689
You could just use an if statement?
@if(User.IsInRole("Administrator"))
{
@*Put input here*@
}
Upvotes: 3