1

In my ASP.NET MVC 4 application, I have a log in box, which is included in the "_Layout" View and shared between all pages. After successful authentication, I would like to present some basic data about the logged in user (First Name, Score, etc.) instead of the log in box. Of course, it also needs to be visible on every page. What would be the best method of implementing this? How can I get the data? Below you can see the screenshots of the box and what I want to achieve.

Before log in:

Before log in

After log in:

After log in

1

1 Answer 1

1

I am using following:

@if(!Request.IsAuthenticated)
{
   //PartialView with Log In form
}
else
{
 // PartialView with after Login from
}
Sign up to request clarification or add additional context in comments.

3 Comments

Ok, that's easy, I already have this in my project. The question is how to pass the data from the controller to the partial view? And in which controller the method should be?
@PGrejc In that case it is very complex question. You should show, what have you tried to do - your models, controller etc. You may have your methods in any controller you want. As to passing data - how it is different from passing any other data?
I've used the method described here link and it worked perfectly for me. Now I have: @if(!Request.IsAuthenticated) { //@Html.Action(...) renders partial view with log in form } else { //@Html.Action(...) renders partial view with user data } Thanks for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.