0

The following rout registration works for my asp.net MVC application

    routes.MapRoute("TrackingChannels", "TrackingChannels/{action}",
        new { controller = "TrackingChannels", action = "Index" });

When I change it to catch this url,

I get resource not found error

for localhost:85\dis\TrackingChannels

        routes.MapRoute("TrackingChannels", "Dis/TrackingChannels/{action}",
            new { controller = "TrackingChannels", action = "Index" });

How can I fix this?

Elad Benda
  • 35,076
  • 87
  • 265
  • 471
  • Setting up a project template with what you have gives me no problems. I can navigate to `/dis/trackingchannels` and the index view is located successfully. – John H Apr 19 '12 at 15:55
  • The only thing I can think of is that you're using backslashes instead of forwardslashes but I can't reproduce that here (in fact, all of my browsers either change backslashes to forwardslashes or give me an error dialog.). Would you like me to post details of what's working for me? – John H Apr 19 '12 at 19:42

1 Answers1

0

Alright, I need to go out so I'll post this now as I don't know how long I'll be.

I setup a default MVC 3 project and changed the routing to match your case.

Global.asax:

public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    routes.MapRoute(
        "TrackingChannels", 
        "Dis/TrackingChannels/{action}", 
        new { controller = "TrackingChannels", action = "Index" }
    );

    routes.MapRoute(
        "Default",
        "{controller}/{action}/{id}",
        new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    );
}

Added a TrackingChannelsController:

public class TrackingChannelsController : Controller
{
    public ActionResult Index()
    {
        return View();
    }

    public ActionResult Test()
    {
        return View();
    }
}

I deliberately added the Test action to see if /dis/trackingchannels/{action} would also work. Then I added a couple of views which resulted in the following project structure:

Project setup

Finally, here's the results of specifying the URLs in the browser:

First with /dis/trackingchannels:

TrackingChannels Index

Second with /dis/trackingchannels/test:

TrackingChannels Test

The only thing I can say without seeing your project is to double check the URL is matching the correct route. To do that you can use Phil Haack's RouteDebugger.

John H
  • 14,422
  • 4
  • 41
  • 74