IgorShare Thoughts and Ideas

Consulting and Training

Adding Nancy to the existing ASP.NET MVC site

Posted by Igor Moochnick on 04/08/2012

There is an issue adding Nancy to the ASP.Net MVC site due to a simple fact that MVC controls the routes not through the web.config but through the routing table.

If you adding Nancy to the existing MVC site – make sure to remove the sub-route that controlled by Nancy from the routing table.

Here how it works:

1. Follow all the steps from the Nancy Documentation Wiki

2. Add your module and make sure that it has an “offset” path (via inheritance)

public Module() : base("/nancy")

3. Remove the “nancy” route from the Routing table in the Global.asax.cs


5 Responses to “Adding Nancy to the existing ASP.NET MVC site”

  1. Brian Bolger said

    Hi, it’s important to note that the sequencing is important here, i.e. if you put the IgnoreRoute call before existing MapHttpRoute & MapRoute calls it works. But placing it after those doesn’t.

    Good post though – thanks!

  2. Andrew Ashbacher said

    What about the other way around? I’m having issues embedding an MVC 2 application within a Nancy site. Check out my question on SO here: http://stackoverflow.com/questions/11973158/add-an-mvc-2-application-to-a-nancy-site-in-iis-7

  3. Oops! I’ve now got it working! Delete all these comments 🙂

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: