Debugging WhoCanHelpMe

Jan 12, 2010 at 7:49 PM

Hi,

I’m having problems debugging this code with VS.Net.  I can run the build scripts (RunFirst.cmd and FullBuild.cmd) without failure and load the solution into Visual Studio 2008 Professional SP2.  Since I don’t have Team System DB edition, the solution doesn’t load the db project, so instead I run the create-db-and-data.sql script on my local install of SQL Server 2008 Developer.

When I try to run and debug the WhoCanHelpMe.Web project, which is setup to use the VS Development Web Server, I get a web page lacking any css or graphics with the “It's gone a bit pear shaped... And it's your fault.” error message.

Elmah logs 10 errors that various paths were not found ('/Views/_Content/img/logo.png', '/Views/_Content/css/reset.css', etc), as well as this error:

The controller for path '/Default.aspx' could not be found or it does not implement IController

This exception occurs on the httpHandler.ProcessRequest(httpContext) line of Default.aspx’s OnInit() method.

I’m running Windows XP SP3, with Visual Studio.Net 2008 Professional SP1 (installed Configuration Section Designer) and Sql Server 2008 Developer.

I haven’t had any problems like this in any of the SharpArch or MVC projects I’ve created before.
Any suggestions on configuring my setup so I can debug the code?

Thanks
Dan

Jan 12, 2010 at 11:57 PM
Edited Jan 12, 2010 at 11:58 PM

Hi Dan,

The problem you are encountering sounds very similar to this:

 

Installation Issues   

 

http://whocanhelpme.codeplex.com/Thread/View.aspx?ThreadId=79838

 

Another thing you can try is to run it using IIS instead of the VS web server (Cassini).

 

Hope this helps.

Best regards,

Martin

Jan 13, 2010 at 3:07 PM

Hi Martin,

Thanks for the link, the changes to the Views folder’s web.config fixed the paths not being found errors.  So now I have graphics and style sheets giving me that nauseating green look (I’m not sure which is worse, the color scheme of the site or being constantly blamed for this thing going pear shaped ;-)

Anyways, I did try switching to using IIS, but there were still problems with paths for various parts of the page as well as other path problems not using the .mvc extension.  More trouble than it was worth as using Cassini is supposed to avoid all of that.

Finally, I got rid of the “The controller for path '/Default.aspx' could not be found or it does not implement IController” error by replacing the code in the Default.aspx with the standard Default.aspx code, specifically:

    protected override void OnInit(EventArgs args)
    {
        //var httpContext = HttpContext.Current;
        //HttpContextBase contextWrapper = new HttpContextWrapper(httpContext);
        //var routeData = GetRouteData(contextWrapper);
        //var httpHandler = routeData.RouteHandler.GetHttpHandler(new RequestContext(contextWrapper, routeData));
        //httpHandler.ProcessRequest(httpContext);

        HttpContext.Current.RewritePath(Request.ApplicationPath, false);
        IHttpHandler httpHandler = new MvcHttpHandler();
        httpHandler.ProcessRequest(HttpContext.Current);
    }


Regards
Dan

 

Coordinator
Jan 13, 2010 at 5:25 PM

I must admit that I develop the code in the root of a new site in IIS 7 - as then the code is deployable directly to our production box - so you might have to give that a go.

What's wrong with the green! It's vibrant! ;D

Jan 13, 2010 at 5:54 PM

I don't have access to a clean IIS6 install either.

Man, the days before IIS7 were quite the suck. :D

In all seriousness, it looks like there may be some out of the box issues with WCHM and IIS6. If I get some free time I'll try to give it a spin and create an Issues accordingly.

Thanks for the additional details, djs!

Jan 13, 2010 at 6:24 PM

Hi Howard and Martin,

What OS are you running on your desktop? Windows Server 2008, Vista or Win7?  I guess my problem is being stuck in the past with WinXP, but then I thought one advantage of using Cassini was that it was compatible with Asp.Net MVC and didn't need any of the workarounds needed by IIS6/Win2k3 and IIS5.1/WinXP.

Regards
Dan

 

 

Coordinator
Jan 13, 2010 at 7:10 PM

I dual boot into Win2k8 & Win7 - both 64bit. I dev'd WCHM on both platforms to make sure it worked - must admit that XP was never really a vector for me.

May 5, 2010 at 1:43 PM
Edited May 5, 2010 at 1:46 PM

I have to put these line to make it work on WIN7 Ultimate + VS2008

    protected override void OnInit(EventArgs args) {
        var httpContext = HttpContext.Current;
        HttpContextBase contextWrapper = new HttpContextWrapper(httpContext);
        var routeData = GetRouteData(contextWrapper);


        routeData.Values[ "controller" ] = "Home";


        var httpHandler = routeData.RouteHandler.GetHttpHandler(new RequestContext(contextWrapper, routeData));
        httpHandler.ProcessRequest(httpContext);
    }

because there was default.aspx value as controller name.

 

BTW html post editor doesn't work on Chrome browser.