2013-05-10 106 views
0

我在Centos 6.4上安裝了來自源代碼的mono,以測試msc asp網站。 它似乎罰款的所有工作,但 某些頁面在Debian返回該錯誤asp.net on mono無法映射路徑'/'

System.InvalidOperationException 
Failed to map path '/' 

Description: HTTP 500.Error processing request. 
Details: Non-web exception. Exception origin (name of application or object): 
System.Web. 
    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.DirectoryExists (System.String virtualDir) [0x00000] in <filename unknown>:0 
    at System.Web.Configuration.WebConfigurationManager.FindWebConfig (System.String path, System.Boolean& inAnotherApp) [0x00000] in <filename unknown>:0 
    at System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration (System.String path, System.String site, System.String locationSubPath, System.String server, System.String userName, System.String password, Boolean fweb) [0x00000] in <filename unknown>:0 
    at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName, System.String path, System.Web.HttpContext context) [0x00000] in <filename unknown>:0 
    at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName, System.String path) [0x00000] in <filename unknown>:0 
    at System.Web.Security.SqliteMembershipProvider.Initialize (System.String name, System.Collections.Specialized.NameValueCollection config) [0x00000] in <filename unknown>:0 
    at System.Web.Configuration.ProvidersHelper.InstantiateProvider (System.Configuration.ProviderSettings providerSettings, System.Type providerType) [0x00000] in <filename unknown>:0 
    at System.Web.Configuration.ProvidersHelper.InstantiateProviders (System.Configuration.ProviderSettingsCollection configProviders, System.Configuration.Provider.ProviderCollection providers, System.Type providerType) [0x00000] in <filename unknown>:0 
    at System.Web.Security.Membership..cctor() [0x00000] in <filename unknown>:0 

我也做了同樣的事情,它工作正常。

你有什麼建議嗎?

回答

0

找到所有你Server.MapPaths與變革

Server.MapPaths(@ 「\」)

Server.MapPaths(Path.DirectorySeparatorChar)

+0

在web.config中? 我沒有找到那個標籤... – user2369620 2013-05-10 12:00:44

-1

我有相同的錯誤,完全相同的堆棧跟蹤。 剛剛啓動apache時,它僅發生在第一個請求上。第一次請求後,錯誤沒有發生。

我通過移除WebMatrix.WebData.dll

這當您使用SimpleMembershipProvider,它可能會在MVC4影響OpenAuth功能將可能有一些後果解決了這個。

+0

它確實提供了我的問題的答案,它可能會爲其他人回答問題。 但上面的評論沒有。 如果我的回答不明白,隨時問! – Tidbit 2014-11-10 18:13:24

0

你檢查過你的視圖文件中的路徑嗎?正如一個提醒:

「/」像<script src="/myScript.js"></script>映射到你的/sites-available/.conf定義DocumentRoot文件夾中,也可能是類似的/ var/WWW

「〜/」像<script src="@Url.Content("~/scripts/script1.js")"></script>映射到您的mvc應用程序的路徑,它可能是事端/ var/www/site1

'../'會嘗試訪問DocumentRoot文件夾上的一個文件夾。這實際上可能被你的apache站點配置禁止(推薦)。

另請注意,如果您從monodevelop/xspServer運行您的mvc應用程序,文檔根目錄和mvc應用程序路徑實際上是相同的,但是如果您在apache上安裝mvc應用程序,它們可能不是相同的路徑。發生

0

此錯誤的原因是單聲道的System.Web中的錯誤

它包含此檢查(https://github.com/mono/mono/blob/mono-3.2.1-branch/mcs/class/System.Web/System.Web/HttpRequest.cs#L1565

if (!isAppVirtualPath && !virtualPath.StartsWith (appVirtualPath, RuntimeHelpers.StringComparison)) 
     throw new InvalidOperationException (String.Format ("Failed to map path '{0}'", virtualPath)); 

爲了解決這個問題,你可以發表評論在單surce代碼和再這些線路 - 編譯單聲道。 這個bug也是在最新的Mono中。

鏈接:

https://bugzilla.xamarin.com/show_bug.cgi?id=24457