What is the easiest way to clone a current instance of an HttpContext request?
I am developing an application in Asp.net MVC v1 . I updated the usual features of PartialView to actually have subcontrollers that are very similar but have their own context. When you use PartialViews, you must fill in the view data for a partial view in the action of the main view controller. I created my own functionality that allows you to call controller actions from a view. This way I get:
- I do not need to provide sub-task data in the action of my main view controller.
- subcontroller methods can manipulate data encapsulated without any relation to other views / controllers.
The problem is that every subcontroller request uses an HttpContext. Therefore, when I set some HttpContext.Item object to a sub-controller, it actually populates the HttpContext of the actual request.
This is why I want to clone an HttpContext. I already use:
HttpContext subContext = new HttpContext(request, response);
but this sets nothing but a request and a response. But I will probably also need other properties and collections ... As a session, elements, user ... etc.
source share