Mono Asp.Net MVC and Nginx

I’ve been using Mono ASP.Net for a while with Nginx as the server. I recently started playing around with ASP.Net MVC and discovered that it doesn’t play nice when using Nginx as the server. To make ASP.Net work with Mono and Nginx you need to download the Mono source from here. And then modify the file mcs/class/System.Web.Routing/System.Web.Routing/Route.cs
in particular comment out the following lines in the GetRouteData function

if (pathInfo != String.Empty)
throw new NotImplementedException();

If you comment out the above two lines your MVC website should work just fine when hosting it using Mono and Nginx. I don’t know if there are any negative consequences for commenting out the above two lines but I have not encountered any.


4 thoughts on “Mono Asp.Net MVC and Nginx

  1. Pingback: ASP.NET MVC Archived Blog Posts, Page 1

  2. I was having similar problems using fastcgi and Debian (the hosting setup on dreamhost), and I found the answer to the problem was not to comment the code out, but to replace the code with

    if (pathInfo != String.Empty) {
    	path = path + pathInfo;

    This allows pages to be routed correctly (looks like fastcgi directs the HttpRequest differently from mod_mono, so the check is incorrect).

    I hope this helps, took me a day or so of debugging to work this one out.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s