Server.Transfer from WebForms ashx handler to MVC 3

1.1k Views Asked by At

I'm trying to do a Server.Transfer from an ASP.NET ashx handler to a ASP.NET MVC 3 page.

I don't want to use Server.Redirect because I do not want the URL to change.

Is this possible?

1

There are 1 best solutions below

0
On

You may try the following in your generic HTTP handler:

public void ProcessRequest(HttpContext context)
{
    var routeData = new RouteData();
    routeData.Values["controller"] = "Home";
    routeData.Values["action"] = "Index";
    IController controller = new HomeController();
    controller.Execute(new RequestContext(new HttpContextWrapper(context), routeData));
}

Obviously this would only work if the Generic HTTP handler is part of the ASP.NET MVC application.

If it is not the same application an HTTP redirect is your only bet.