Use a partial view because you have different views based on login status. Return one view for anonymous users with the / lunk login form to the registration page and a second view for registered users.
Partial views can have their own models that do not need to inherit from the main view model.
Inherited models can cause problems later (this makes using html.EditForModel() or .DisplayForModel() difficult, as they also display common fields of the main view).
Oh, and generally, for bad vision practice, relying on anything outside the model is your Test on Request.IsAuthenticated can be fine, but if you want to be absolutely correct, you must have the model.IsAuthenticated property that is set by the action. However, switching views will completely fix this problem.
Edit: Last improvement. In lines like this:
Welcome <b><%= Html.Encode(Page.User.Identity.Name) %></b>!
Instead, run:
Welcome <b><%: Page.User.Identity.Name %></b>!
In fact, it would be even better to hit only the model:
Welcome <b><%: model.Username %></b>!
(Note the <%: not <%= ). This tag form indicates that the content should be encoded in HTML. What's even better, if it encounters a string , it will encode it. If he encounters an HTMLString , he will not. All .Net MVC functions return an HTML string or string if necessary, so you can do this:
<%: html.EditFor(x => x.fieldname) %> <%: model.somefield %>
The first will NOT be html encoded as EditFor() returns an HTMLString . The second WILL will be encoded (if somefield is the standard string)
This will make your code tidier and more reliable. You can also use this to dynamically generate HTML code if you need to code it / not appropriate. For example, we have some helper functions for processing, including CSS / JS. They return HTMLStrings ...
<%: Helper.IncludeCSS("SomeCSS.css") %>