Steve Sanderson "Partial Request"

I followed a blog post written by Steve Sanderson at blog.codeville.net/2008/10/14/partial-requests-in-aspnet-mvc . It all works great if you follow it exactly, but I was hoping someone might have a look at it and be able to help me adjust it a bit.

I basically have this "partial request" calling from one controller to another and it works great. Then I want to view the data and create a dropdown. The problem is I need to convert it to IEnumerable for this, but it doesn't tell me that I can't convert void to IEnumerable.

The lkine error is in the view and is:

foreach (var category in (IEnumerable<MyObject>) ((PartialRequest)ViewData["ReturnedData"]).Invoke(ViewContext))

      

Obviously, knowing how to answer this is difficult without seeing the code. This is all in the above post, but since it is quite long, I don't want to post it here. I understand that this allows this complex question to be answered, and I hope someone prepares this post and can help.

Thanks in advance.

0


source to share


1 answer


The PartialRequest Invoke method returns nothing, it writes the HTML that the request generates for the response. The idea is that you can call a controller action that renders the MVC View User control, not the view. You can make a partial request to this controller action and force it to directly control the response flow rather than using Html.RenderPartial. Since the control is written directly to the response, there is no way for you to interact with it.



+3


source







All Articles