SergioB
SergioB

Reputation:

ASP.NET MVC: Stack overflow error when calling Html.RenderPartial()

I have a Controller called ActivationController with a LogOn action, which renders the view LogOn.aspx. LogOn.aspx renders a partial view called LogOn.ascx:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    LogOn
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Account Activation Step 1 - Log On</h2>

    <p>
        <%Html.RenderPartial("LogOn")<;%>
    </p>

</asp:Content>

When calling the action i'm getting a "Stack Overflow" exception:

An unhandled exception of type 'System.StackOverflowException' occurred in System.Web.Mvc.dll

Any clue?

Thanks in advance!

Upvotes: 2

Views: 1457

Answers (2)

SergioB
SergioB

Reputation:

Don't bother to reply, i found the issue.

The problem was that partial view should have a different name than the view. :P

Thanks anyway!!

Upvotes: 6

Josh E
Josh E

Reputation: 7424

This looks wrong:

<%Html.RenderPartial("LogOn")<;%>

it should look like this:

<% Html.RenderPartial("LogOn");%>

Upvotes: 1

Related Questions