Using a custom MvcHttpHandler v2.0 Breaking change from 1.0 to 2.0 ?

Posted by Myster on Stack Overflow See other posts from Stack Overflow or by Myster
Published on 2010-03-18T21:18:56Z Indexed on 2010/03/18 21:21 UTC
Read the original article Hit count: 692

Hi

I have a site where part is webforms (Umbraco CMS) and part is MVC This is the HttpHandler to deal with the MVC functionality:

public class Mvc : MvcHttpHandler
{
    protected override void ProcessRequest(HttpContext httpContext)
    {
        httpContext.Trace.Write("Mvc.ashx", "Begin ProcessRequest");
        string originalPath = httpContext.Request.Path;
        string newPath = httpContext.Request.QueryString["mvcRoute"];
        if (string.IsNullOrEmpty(newPath))
            newPath = "/";

        httpContext.Trace.Write("Mvc.ashx", "newPath = "+newPath );

        HttpContext.Current.RewritePath(newPath, false);
        base.ProcessRequest(HttpContext.Current);
        HttpContext.Current.RewritePath(originalPath, false);
        }
}

Full details of how this is implemented here This method works well in an MVC 1.0 website. However when I upgrade this site to MVC 2.0 following the steps in Microsoft's upgrade documentation; everything compiles, except at runtime I get this exception:

Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /mvc.ashx

Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927

This resource and it's dependencies are found fine in MVC 1.0 but not in MVC 2.0, is there an extra dependency I'd need to add? Is there something I'm missing? Is there a change in the way MVC 2.0 works?

© Stack Overflow or respective owner

Related posts about asp.net-mvc-2

Related posts about asp.net-mvc