首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Nginx + FastCGI + Mono WebAPI 2抛出ArgumentNullException: Value不能为空。参数名称:路径

Nginx + FastCGI + Mono WebAPI 2抛出ArgumentNullException: Value不能为空。参数名称:路径
EN

Stack Overflow用户
提问于 2016-10-04 07:20:08
回答 1查看 536关注 0票数 0

我的设置:fastcgi-mono-server Client (http:8080) Nginx (FastCGI:9000)

我想托管ASP.NET MVC 4应用程序,完全由WebAPI 2控制器、配置等构建,在Ubuntu上使用Mono 4和fastcgi-mono-server4,但是对于WebAPI路由,它返回400

代码语言:javascript
复制
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路由匹配的urls上,例如/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 urls时,它输出如下内容:

代码语言:javascript
复制
[0x7f8276459700:] EXCEPTION handling: System.ArgumentNullException: Value cannot be null.
Parameter name: path

我的代码不执行任何IO操作,只执行数据库(但我们还没有完成)。如前所述,行为只发生在与WebAPI路由匹配的urls上,例如/api/products,这意味着配置工作,我认为这与环境有关。

EN

回答 1

Stack Overflow用户

发布于 2017-02-25 17:31:11

之所以发生这种情况,是因为缺少所需的参数。

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

代码语言:javascript
复制
fastcgi_param  PATH_INFO          "";

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

代码语言:javascript
复制
server {
    listen 80;
    ...
    location / {
        ...
        fastcgi_pass 127.0.0.1:9000;
        include /etc/nginx/fastcgi_params;
    }
}

当然,您可能缺少一个不同的参数。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39846405

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档