ASP.NET MVC exception when invoking partial view from the main page

I get an error when I try to call a partial view from the wizard.

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> 

Action in the Members controller

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

Then I call up a partial view from the main page :

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

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

{Unable to evaluate expression because current stream is in state.}

I do not understand how this error works. Any help would be greatly appreciated!

+4
source share
3 answers

I have seen this error before. In my case, this happened when I returned the View () call, not the PartialView () for Html.RenderAction or Html.Action in my action methods.

Hope this helps someone.

+15
source

What happens when changing

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

to

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

Also note that there is; at the end of the team. Skip this and you will get another error.

+1
source

I got the same thing because I loaded a user control that was essentially in the menu bar but full Html.Action () and not Html.ActionLink (), so it constantly called the action and because it returned to the page , which inherited the same main page, called it again ... and again ... and again.

So my problem was that I used the wrong keyword.

+1
source

Source: https://habr.com/ru/post/1309482/


All Articles