This project is read-only.

Default action not working

Aug 2, 2012 at 9:31 AM

I've got a project I'm using this library on, and I'm having an issue with the default action not being picked up in one of my routes. The route that shows up in routes.axd is as follows:

routes.MapRoute(null, "product/{action}", 
    new { controller = @"Home", action = @"Index" }, 
    new { action = @"Index|SelectCustomer|CustomerSelect" }, 
    new[] { "product.Web.Controllers" });

Which looks correct as far as I can tell. The Home controller's default action should be index. I'm then linking to the index action with:

<a class="appLink" href="@Url.Action("Index","~~product.Home")"></a>

Which generates the URL of:

<a class="appLink" href="/webdirroot/product"></a>

Which is also, as far as I can tell, correct.

However, going to that URL results in a 404. But, going to /webdirroot/product/index returns the proper page.

Have I run into a bug, or am I missing something?

Aug 2, 2012 at 3:05 PM

Please send me a small project that reproduces the issue to

Aug 3, 2012 at 4:35 PM

Ok, I managed to finally hunt this down in the process of building a sample project. It turns out I had a real directory in the project left over from something I was trying previously that shared its name with the route. I'm assuming that since that directory existed, IIS decided to serve the request from there when it was just the directory name, and when the action was on there, that didn't exist, so IIS served it with the runtime.

Sorry bout the false alarm

Aug 3, 2012 at 4:43 PM

Glad to know you solved it. You can use the RouteCollection.RouteExistingFiles property to avoid this issue.

Marked as answer by maxtoroq on 10/15/2013 at 9:24 AM