开发者

Server.Transfer from WebForms ashx handler to MVC 3

开发者 https://www.devze.com 2023-02-12 04:44 出处:网络
I\'m trying to do a Server.Transfer from an ASP.NET ashx handler开发者_如何转开发 to a ASP.NET MVC 3 page.

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号