4

I'm getting a stack overflow error when I try to call a partial view from the master.

The Partial View:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>

<form action="/members/TestLoginProcess/" method="post">
U: <input type="text" name="mUsername" /><br />
P: <input type="password" name="mHash" /><br />
<button type="submit">Log In</button>
</form>

The Action in the "Members" controller

[ChildActionOnly]
    public ActionResult TestLogin()
    {
        return PartialView();
    }

Then I call the partial view from the master page:

<!--Excerpt from wopr.master--> 
<%= Html.Action("TestLogin", "Members")%>

When I go into debug mode the master page returns this error:

{Cannot evaluate expression because the current thread is in a stack overflow state.}

I don't understand how this error is getting triggered. any help would be much appreciated!

6
  • What's the call stack in the debugger? Commented May 11, 2010 at 22:21
  • I'm not sure I understand what you mean. I'm new to Visual Basic Web Developer so sorry for my ignorance. Commented May 11, 2010 at 22:24
  • is this what you're asking for? :An unhandled exception of type 'System.StackOverflowException' occurred in System.Core.dll Commented May 11, 2010 at 22:25
  • I did a quick google search on vwd call stack... is this helpfull? :> App_Web_jk8x_wbh.dll!ASP.views_shared_wopr_master.__Render__control1(System.Web.UI.HtmlTextWriter __w = {System.Web.UI.HtmlTextWriter}, System.Web.UI.Control parameterContainer = {ASP.views_shared_wopr_master}) Line 13 + 0x25 bytes C# Commented May 11, 2010 at 22:27
  • 1
    What function(s) are repeated many times in the call stack window? Commented May 11, 2010 at 22:39

3 Answers 3

15

I have seen this error before. In my case it happened when i returned a call to View() rather than PartialView() for Html.RenderAction or Html.Action in my action methods.

Hope this helps someone.

Sign up to request clarification or add additional context in comments.

Comments

1

What happens when you change

<%= Html.Action("TestLogin", "Members")%>

to

<%= Html.RenderPartial("TestLogin", "Members");%>?

Please also note there is a ; at the end of the command. Miss this and you'll get another error.

2 Comments

Thanks for the help and the wishes. Unfortunately, when I tried RenderPartial I got this error: Cannot implicitly convert type 'void' to 'object'
I took the "=" out and that took care of that error. New errors now :-( I'm gonna troubleshoot this for a while before updating this post.
1

I got the exact same thing because I was loading a user control that was essentially a menu bar, but full of Html.Action(), rather than Html.ActionLink(), so it was continuously calling the Action and because it went back to a page that inherited the same masterpage, was calling it again...and again...and again.

So yeah my problem was I was using the wrong keyword.

Comments

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.