Home / Fix Argument cannot be null, Parameter name: path on Nginx/Mono

Fix Argument cannot be null, Parameter name: path on Nginx/Mono

When migrating a mono application / web service running on one server to a new server I got an error telling me that the “Argument cannot be null” and “Parameter name: path”. This post shows the full error message and the additional configuration options that needed to be set to fix it.

Nginx config

The nginx config to pass the requests through to the mono server was as follows:

location /myscript.asmx {
    include /etc/nginx/fastcgi_params;

Error message

The error message I was getting was this:

Application Exception
Argument 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.FileSystemInfo.CheckPath (System.String path) [0x00000] in <filename unknown>:0 
  at System.IO.DirectoryInfo..ctor (System.String path, Boolean simpleOriginalPath) [0x00000] in <filename unknown>:0 
  at System.IO.DirectoryInfo..ctor (System.String path) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:.ctor (string)
  at Mono.WebServer.FastCgi.WorkerRequest.GetFilePath () [0x00000] in <filename unknown>:0 
  at Mono.WebServer.MonoWorkerRequest.GetFilePathTranslated () [0x00000] in <filename unknown>:0 
  at Mono.WebServer.MonoWorkerRequest.AssertFileAccessible () [0x00000] in <filename unknown>:0 
  at Mono.WebServer.MonoWorkerRequest.ProcessRequest () [0x00000] in <filename unknown>:0 
Version Information: 2.11.3 (tarball Fri Aug 31 16:23:09 NZST 2012); ASP.NET Version: 2.0.50727.1433

The solution

The fastcgi_params file which is included needed a couple of extra settings in it to work. By adding the following to the end of that file and restarting nginx, the problem was solved:

fastcgi_param  PATH_INFO          "";
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

Linux distros

This should work for RHEL (Red Hat Enterprise Linux) 6 and CentOS 6, and possibly earlier versions of these Linux distros as well, and other Linux distros. I ran these commands on RHEL6 on versions of Nginx, Mono and xsp all compiled from source.