Search code examples
asp.net-mvc-3monofastcgilighttpd

Mono MVC3 failed to map path


I'm trying to get a MVC3 application working under mono, and everything was going well until I deployed to my server...

I'm currently getting:

Failed to map path '/projects/_ViewStart.cshtml'

System.InvalidOperationException: Failed to map path '/projects/_ViewStart.cshtml'
  at System.Web.HttpRequest.MapPath (System.String virtualPath, System.String baseVirtualDir, Boolean allowCrossAppMapping) [0x00000] in <filename unknown>:0 
  at System.Web.HttpRequest.MapPath (System.String virtualPath) [0x00000] in <filename unknown>:0 
  at System.Web.Hosting.HostingEnvironment.MapPath (System.String virtualPath) [0x00000] in <filename unknown>:0 
  at System.Web.Hosting.DefaultVirtualPathProvider.FileExists (System.String virtualPath) [0x00000] in <filename unknown>:0 
  at System.Web.WebPages.FileExistenceCache.FileExists (System.String virtualPath) [0x00000] in <filename unknown>:0 
  at System.Web.WebPages.VirtualPathFactoryManager.PageExistsInVPP (System.String virtualPath, Boolean useCache) [0x00000] in <filename unknown>:0 
  at System.Web.WebPages.VirtualPathFactoryManager.PageExists (System.String virtualPath, Boolean useCache) [0x00000] in <filename unknown>:0 
  at System.Web.WebPages.WebPageExecutingBase.FileExists (System.String path, Boolean useCache) [0x00000] in <filename unknown>:0 
  at System.Web.WebPages.StartPage.GetStartPage (System.Web.WebPages.WebPageRenderingBase page, System.String fileName, IEnumerable`1 supportedExtensions) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.RazorView.RenderView (System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer, System.Object instance) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.BuildManagerCompiledView.Render (System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.ViewResultBase.ExecuteResult (System.Web.Mvc.ControllerContext context) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19 () [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter (IResultFilter filter, System.Web.Mvc.ResultExecutingContext preContext, System.Func`1 continuation) [0x00000] in <filename unknown>:0 

Errors. I can confirm that all the files and DLL's exist, but the path doesn't look right, surely it should be looking in the Views folder where things DO exist?

Is there some sort of setting I need to set to ensure that it looks in the correct Views location? I also notice there is no "~" character before the file path...

I've looked around the net and tried various solutions, but none seem to work..


Solution

  • Have a look into your Apache configuration, for me it said

    Failed running '/usr/bin/mod-mono-server2 --filename /tmp/mod_mono_server_bla --applications /testmono:/var/www/ModMonoMvc3Application --nonstop (null) (null) (null) (null) (null) (null) (null)'. Reason: No such file or directory

    because I misunderstood the configuration option AddMonoApplications. It should read something like this:

    # "default" is defined in mods-available/mod_mono.conf
    AddMonoApplications default "/testmono:/var/www/ModMonoMvc3Application"
    
    <Location /testmono/>
        SetHandler mono
    </Location>
    

    I accidentally wrote "bla" instead of "default" because I thought it was the application name, but in fact it defines which server executable is started.