I would like to know if what the best method is for creating a login type control i.e. When not logged in, offers links to login etc and when logged in offers the users name and setting etc.
I was thinking that the proper way to go about this is a partial view?
But does mean i need to insert IFs in the partial view to render depending if logged in or not?
I don't know if this is the best way? Maybe its a bit messy?
I would really love some feedback or any ideas.
I am using MVC 3
If you open up Visual Studio 2010 and create a new ASP.NET MVC Website (not the empty one), they have an example of how you could do this.
It is pretty much how you described it. It would be something similar to the following
@if(Request.IsAuthenticated) {
Hello @Page.User.Identity.Name
} else {
@Html.ActionLink("Sign In", "SignIn", "Account")
}
Given how short and simple this is, I don't think it would be considered messy.