I'm trying to convert the existing web project to MVC. I made a standard MVC project in VS 2012. It added routing configuration. My existing project already contained routing entry used by WCF services. So now routes are configured like this:
// Was here before, used by services
routes.Add(new ServiceRoute("AppServer", new WebServiceHostFactory(), typeof(MyService)));
// the rest is added by vs to configure a default controller
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
I realized that service part should always go first because it is more restrictive. Service doesn't work if it is put to the end. But now the problem is that
@Html.ActionLink("text", "MyAction", "MyController")
now generates me the links of type
http://localhost/AppServer?action=MyAction&controller=My
instead of
http://localhost/My/MyAction
what I would expect.
Does anyone know how to make service route and mvc-related routes "live in peace" i.e. not to affect each other?