2

I am receiving a weird error message when i try and use @Html.Action() in my view?

here is the view code:

@Html.Action("Index", "Clients")

And here is the controller:

public class ClientsController : Controller
{
    private ROUTING_DBV6Entities db = new ROUTING_DBV6Entities();

    // GET: Clients
    public async Task<ActionResult> Index()
    {
        return View(await db.Clients.ToListAsync());
    }
}

And here is the error message which I have recieved:

{Cannot evaluate expression because the current thread is in a stack overflow state.}
13
  • Which controller/action is that View for? Commented Jul 9, 2014 at 9:56
  • 9
    You have created an infinite loop. @Html.Action("Index", "Clients") calls the ClientsController.Index which then calls the View Index which then calls @Html.Action("Index", "Clients"). Maybe you wanted an action link. Commented Jul 9, 2014 at 9:58
  • 1
    Have a look at partials referencing Index, that might casue a never ending story. Commented Jul 9, 2014 at 9:59
  • 1
    Side note: Do not forget to dispose your ROUTING_DBV6Entities. Commented Jul 9, 2014 at 10:09
  • 1
    @Silvermind Unless Zapnologica is taking the dangerous route of a shared context Commented Jul 9, 2014 at 10:17

1 Answer 1

1

Are you calling this from _Layout.cshtml?

try returning a partial view - return PartialView(await db.Clients.ToListAsync());

or add this to the clients view @{ Layout = null; }

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

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.