ASP.NET MVC调用从母版页的局部视图时,堆栈溢出异常 [英] ASP.NET MVC stack overflow exception when calling a partial view from master page

查看:127
本文介绍了ASP.NET MVC调用从母版页的局部视图时,堆栈溢出异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个堆栈溢出错误,当我尝试调用从主的局部视图。

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

局部视图:

<%@ 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>

中的成员控制器的动作

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

然后,我打电话从母版页的局部视图

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

当我进入调试模式母版页返回此错误:

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

{不能因为当前线程堆栈溢出状态评估前pression}

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

我不明白,这个错误是如何得到触发。任何帮助将是非常美联社preciated!

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

推荐答案

我以前看过这个错误。在我的情况发生了,当我回到调用视图(),而不是PartialView()在我的操作方法Html.RenderAction或Html.Action。

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.

希望这可以帮助别人。

这篇关于ASP.NET MVC调用从母版页的局部视图时,堆栈溢出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆