1

I am trying to get my login partial to read the user's first and last name from my database. Therefore, I am trying to call an action from my layout instead of the view partial.

@If Request.IsAuthenticated Then

      @<text><div class="authBox">Welcome <strong>@User.Identity.Name</strong>!
      </div></text>

Else

I am getting a stack overflow exception on this line in my layout:

@Html.Action("RenderLogOnPartial", "Employee")

Here is the action I am calling:

    ' 
    ' GET: /Employee/RenderLogOnPartial
    Public Function RenderLogOnPartial() As ViewResult

        Return View("_LogOnWithValidationPartial")

    End Function

What can I do to get the first and last name into my view partial? Thanks.

1 Answer 1

2

Views will use your layout, which will call your action again, hence the stackoverflow.

Try

Return PartialView("_LogOnWithValidationPartial")
Sign up to request clarification or add additional context in comments.

1 Comment

I didn't know it was such an option to render a partial view. Thanks.

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.