Having logic of selecting action and controller in processrequest

118 Views Asked by At

I have a processrequest method in custom mvc handler.

I like to render specific action based on requestcontext.

following is my code

     public void ProcessRequest(HttpContext context)
    {
       if(Request.QueryString["lid"]!=null && ...){
        IController controller = new ListHell.Controllers.ErrorController();

        var routeData = new RouteData();
        routeData.Values.Add("controller", "Error");
        routeData.Values.Add("action", "Ops");

        var requestContext = new RequestContext(
             new HttpContextWrapper(Context), routeData);
        controller.Execute(requestContext);}
    }

In processrequest I am trying to call controller.execute method. But I am getting error that Context is not defined in current context.

Basically I am trying run specific action based on query string or cookie value before my request hit requested action. how can I do this? I believe I need to do the logic in mvcHandler. please correct me with right path I can follow?

Thanks

0

There are 0 best solutions below