title: custom httphandler in asp.net cannot get request querystring?
body: <p>I've been trying to get <a href="http://memoryleak.me.uk/2009/04/umbraco-and-aspnet-mvc.html" rel="nofollow noreferrer">this</a> to work. It's basically a way to have certain MVC pages work within a webforms cms (umbraco)</p>
  
  <p>Someone tried it before me and had issues with MVC2.0 <a href="https://stackoverflow.com/questions/2473408/using-a-custom-mvchttphandler-v2-0-breaking-change-from-1-0-to-2-0">(see here)</a>, 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.</p>
  
  <p>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: <a href="http://localhost:8080/mvc.ashx?mvcRoute=/home/RSVPForm" rel="nofollow noreferrer">http://localhost:8080/mvc.ashx?mvcRoute=/home/RSVPForm</a>
  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.</p>
  
  <p>Here is the code I use now:</p>
  
  <pre><code>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);
  }
  </code></pre>
  
  <p>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>