Asp.net mvc 3 Mono MVC3未能映射路径

Asp.net mvc 3 Mono MVC3未能映射路径,asp.net-mvc-3,mono,fastcgi,lighttpd,Asp.net Mvc 3,Mono,Fastcgi,Lighttpd,我正在尝试让MVC3应用程序在mono下工作,在我部署到服务器之前一切都很顺利 我目前得到: 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

我正在尝试让MVC3应用程序在mono下工作,在我部署到服务器之前一切都很顺利

我目前得到:

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 
映射路径“/projects/_ViewStart.cshtml”失败
System.InvalidOperationException:未能映射路径“/projects/_ViewStart.cshtml”
位于System.Web.HttpRequest.MapPath(System.String virtualPath、System.String baseVirtualDir、布尔allowCrossAppMapping)[0x00000]中:0
位于:0中的System.Web.HttpRequest.MapPath(System.String virtualPath)[0x00000]处
位于:0中的System.Web.Hosting.HostingEnvironment.MapPath(System.String virtualPath)[0x00000]处
位于System.Web.Hosting.DefaultVirtualPath Provider.FileExists(System.String virtualPath)[0x00000]中:0
位于:0中的System.Web.WebPages.FileExistenceCache.FileExists(System.String virtualPath)[0x00000]处
在System.Web.WebPages.VirtualPathFactoryManager.PageExistsInVPP(System.String virtualPath,布尔useCache)[0x00000]中:0
位于System.Web.WebPages.VirtualPathFactoryManager.PageExists(System.String virtualPath,Boolean useCache)[0x00000]中:0
位于System.Web.WebPages.WebPageExecutingBase.FileExists(System.String路径,布尔useCache)[0x00000]中:0
在System.Web.WebPages.StartPage.GetStartPage(System.Web.WebPages.WebPages UnderingBase页,System.String文件名,IEnumerable`1 supportedExtensions)[0x00000]中:0
位于:0中的System.Web.Mvc.RazorView.RenderView(System.Web.Mvc.ViewContext、System.IO.TextWriter编写器、System.Object实例)[0x00000]处
在System.Web.Mvc.BuildManagerCompiledView.Render(System.Web.Mvc.ViewContext-ViewContext,System.IO.TextWriter-writer-writer)[0x00000]中:0
在:0中的System.Web.Mvc.ViewResultBase.ExecuteSult(System.Web.Mvc.ControllerContext上下文)[0x00000]处
在System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(System.Web.Mvc.ControllerContext ControllerContext,System.Web.Mvc.ActionResult ActionResult)[0x00000]中:0
在System.Web.Mvc.ControllerActionInvoker+c__DisplayClass1c.b__19()[0x00000]中:0
在System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter筛选器,System.Web.Mvc.ResultExecutingContext预文本,System.Func`1 continuation)[0x00000]中:0
错误。我可以确认所有的文件和DLL都存在,但是路径看起来不正确,当然应该在视图文件夹中查找确实存在的东西

是否需要设置某种设置,以确保它位于正确的视图位置?我还注意到文件路径前没有“~”字符


我环顾了一下网络,尝试了各种解决方案,但似乎没有一种是有效的。

对我来说,看看你的Apache配置吧

运行“/usr/bin/mod-mono-server2--filename/tmp/mod_mono_服务器--applications/testmono:/var/www/modmonovc3application--nonstop(null)(null)(null)(null)(null)(null)(null)”失败。原因:没有这样的文件或目录

因为我误解了配置选项
AddMonoApplications
。应该是这样的:

# "default" is defined in mods-available/mod_mono.conf
AddMonoApplications default "/testmono:/var/www/ModMonoMvc3Application"

<Location /testmono/>
    SetHandler mono
</Location>
#“default”在mods available/mod_mono.conf中定义
AddMonoApplications默认值“/testmono:/var/www/ModMonoMvc3Application”
SetHandler单声道

我不小心写了“bla”而不是“default”,因为我以为它是应用程序名,但实际上它定义了启动哪个服务器可执行文件。

我在直接调用时遇到了相同的错误

HttpContext.Current.Server.MapPath(“/”)

HttpContext.Current.Server.MapPath(Path.DirectorySeparatorChar.ToString()) 
然而,这是可行的:

HttpContext.Current.Server.MapPath("~")