2011-12-04 108 views
1

我試圖得到一個MVC3應用程序下單的工作,一切都進行得很順利,直到我部署到我的服務器......單MVC3未能映射路徑

目前我得到:

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 

錯誤。我可以確認所有的文件和DLL的存在,但路徑看起來不正確,當然它應該在事情​​存在的視圖文件夾中查找?

是否需要設置某種設置以確保它在正確的Views位置中顯示?我也注意到有文件路徑前沒有「〜」字符...

我看了看周圍的淨和嘗試各種解決方案,但沒有一個似乎工作..

回答

0

看一看到你的Apache配置,對我來說說

無法運行「的/ usr/bin中/ MOD-單服務器2 --filename的/ tmp/mod_mono_server_bla --applications/testmono:在/ var/WWW/ModMonoMvc3Application --nonstop(空) (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> 

我不小心寫了「喇嘛」,而不是「默認」,因爲我認爲這是應用程序的名稱,但實際上它定義了服務器可執行文件已啓動。

0

我得到的時候直接調用

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

HttpContext.Current.Server.MapPath(Path.DirectorySeparatorChar.ToString()) 

但是這個作品相同的錯誤:

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