开发者

custom httphandler in asp.net cannot get request querystring?

I've been trying to get this t开发者_Python百科o work. It's basically a way to have certain MVC pages work within a webforms cms (umbraco)

Someone tried it before me and had issues with MVC2.0 (see here), I have read the post, did what was announced there, but with or without that code, I seem to get stuck on a different matter.

It seems like, if I call an url, it fires the handler, but fails to request the querystring passed, the variable originalPath is always empty, for example I call this url: http://localhost:8080/mvc.ashx?mvcRoute=/home/RSVPForm the handler is supposed to get the mvcRoute but it is always empty. Thus gets rewritten to a simple / and then returns resource cannot be found error.

Here is the code I use now:

public void ProcessRequest(HttpContext httpContext)
{
        string originalPath = httpContext.Request.Path;
        string newPath = httpContext.Request.QueryString["mvcRoute"];
        if (string.IsNullOrEmpty(newPath))
            newPath = "/";

        HttpContext.Current.RewritePath(newPath, false);
        IHttpHandler ih = (IHttpHandler)new MvcHttpHandler();
        ih.ProcessRequest(httpContext);
        HttpContext.Current.RewritePath(originalPath, false);
}

I would like some new input on this as I'm staring myself blind on such a simple issue, while I thought I would have more problems with mvc itself.


have no time to investigate, but after copying the site over to different locations, using numerous web.config changes (unrelated to this error but was figuring other things out) this error seems to have solved itself. so its no longer an issue, however i have no clue as to what exactly made this to work again.

on a side note

ih.ProcessRequest(httpContext);

should have been,

ih.ProcessRequest(HttpContext.Current);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜