【问题标题】:Nginx + FastCGI + Mono WebAPI 2 throws ArgumentNullException: Value cannot be null. Parameter name: pathNginx + FastCGI + Mono WebAPI 2 抛出 ArgumentNullException: Value cannot be null。参数名称:路径
【发布时间】:2016-10-04 07:20:08
【问题描述】:

我的设置: 客户端 (http:8080) Nginx (FastCGI:9000) fastcgi-mono-server强>

我想在带有 Mono 4 和 fastcgi-mono-server4 的 Ubuntu 上托管 ASP.NET MVC 4 应用程序,完全使用 WebAPI 2 控制器、配置等构建,但对于 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,这意味着配置有效,我想它与环境有关。

【问题讨论】:

    标签: asp.net-mvc asp.net-mvc-4 nginx asp.net-web-api mono


    【解决方案1】:

    发生这种情况是因为缺少必需的参数。

    我今天遇到了这个。我发现在 /etc/nginx/fastcgi_params 中,我需要添加以下行:

    fastcgi_param  PATH_INFO          "";
    

    在服务器配置中,我需要导入这个文件:

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

    当然,您可能缺少其他参数。

    【讨论】:

    • 谢谢。我还必须添加:fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-26
    • 2022-06-10
    • 2019-11-02
    • 2011-11-01
    • 2020-04-26
    • 1970-01-01
    相关资源
    最近更新 更多