开发者

MVC ashx handler

开发者 https://www.devze.com 2023-03-30 09:18 出处:网络
I\'m using MVC3 and want to create a route to an ashx file. I\'ve created an Generic Handler with this code in:

I'm using MVC3 and want to create a route to an ashx file. I've created an Generic Handler with this code in:

    public IHttpHandler GetHttpHandler(RequestContext requestContext)
    {

        var handler = new TileHandler();
        handler.ProcessRequest(requestContext);

        return handler;
    }

I've set a route up in the Global.asax which works fine. However my TileHandler which is an ashx page expects a HttpContext to be pa开发者_C百科ssed to it not a RequestContext. I can overload the method, but it obviously still wants the standard method invoked on call.

My question is therefore how can you use an ashx page passing in a RequestContext object?

Thanks in advance.


Change your TileHandler to inherit from System.Web.Mvc.MvcHandler instead.

Example.

0

精彩评论

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