Stackoverflow Exception using HTML.RenderPartial ASP.NET MVC

Lesson learned. Don’t name your partial views the same as your normal views.

Login.cshtml under Views/Shared
Login.cshtml under Views/Login tries to call Html.RenderPartial(“Login”)

Stackoverflow Exception because the rendering engine ends up searching the Views/Shared after everything else and ends up recursively calling Views/Login/Login.cshtml.

Renaming the shared View to _Login.cshtml obviously fixed the issue.

Partial Views explained:

Leave a Reply

Your email address will not be published. Required fields are marked *