2016-10-04 47 views
0

我的設置: 客戶(HTTP:8080)Nginx的(FastCGI的:9000)FastCGI的,單服務器Nginx + FastCGI + Mono WebAPI 2引發ArgumentNullException:值不能爲空。參數名:路徑

我想舉辦ASP.NET MVC 4應用,完全用的WebAPI 2個控制器,配置等建成,在Ubuntu使用Mono 4和fastcgi-mono-server4,但對的WebAPI路由返回400

System.ArgumentNullException 
Value cannot be null. 
Parameter name: path 

Description: HTTP 400.Error processing request. 
Details: Non-web exception. Exception origin (name of application or object): mscorlib. 
Exception stack trace: 
    at System.IO.DirectoryInfo.CheckPath (System.String path) [0x00006] in <dca3b561b8ad4f9fb10141d81b39ff45>:0 
    at System.IO.DirectoryInfo..ctor (System.String path, System.Boolean simpleOriginalPath) [0x00006] in <dca3b561b8ad4f9fb10141d81b39ff45>:0 
    at System.IO.DirectoryInfo..ctor (System.String path) [0x00000] in <dca3b561b8ad4f9fb10141d81b39ff45>:0 
    at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:.ctor (string) 
    at Mono.WebServer.FastCgi.WorkerRequest.GetFilePath() [0x00035] in <a872d12009ac4a668f0d504d764f1c44>:0 
    at Mono.WebServer.MonoWorkerRequest.GetFilePathTranslated() [0x00001] in <5b4128956e344d60b82a5fd7012fd8a1>:0 
    at Mono.WebServer.MonoWorkerRequest.AssertFileAccessible() [0x00010] in <5b4128956e344d60b82a5fd7012fd8a1>:0 
    at Mono.WebServer.MonoWorkerRequest.ProcessRequest() [0x0000b] in <5b4128956e344d60b82a5fd7012fd8a1>:0 

在我的開發機器上,通過xsp4和通過MonoDevelop「運行」按鈕運行正常。還沒有試過fastcgi-mono-server4,但如果你認爲這是相關的,我會的。

正如我所說的,上述行爲只發生在匹配WebAPI路由的URL上 - 例如, /api/products,這意味着配置工作,我想它與環境有關。

我已經開始fastcgi-mono-server如下:MONO_OPTIONS=--trace=E:System.Exception fastcgi-mono-server4 /appconfigdir=/etc/mono/fastcgi /socket=tcp:127.0.0.1:9000當打的WebAPI的URL它輸出這樣的:

[0x7f8276459700:] EXCEPTION handling: System.ArgumentNullException: Value cannot be null. 
Parameter name: path 

我的代碼沒有做任何IO,只有數據庫(但我們還沒有應用)。正如我所說的,上述行爲只發生在匹配WebAPI路由的URL上 - 例如/api/products,這意味着配置工作,我想它與環境有關。

回答

0

發生這種情況是因爲缺少必需的參數。

今天我遇到了這個。我發現,在/ etc/nginx的/ fastcgi_params,我需要添加以下行:

fastcgi_param PATH_INFO   ""; 

而且在服務器配置,我需要導入此文件:

server { 
    listen 80; 
    ... 
    location/{ 
     ... 
     fastcgi_pass 127.0.0.1:9000; 
     include /etc/nginx/fastcgi_params; 
    } 
} 

當然,你可能缺少一個不同的參數。

相關問題