custom httphandler in asp.net cannot get request querystring?
Posted
by Sander
on Stack Overflow
See other posts from Stack Overflow
or by Sander
Published on 2010-04-26T14:53:04Z
Indexed on
2010/04/27
15:33 UTC
Read the original article
Hit count: 560
i've been trying to get this to work. its basicly 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 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 :p
Edit 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.
© Stack Overflow or respective owner