MVC2 Routing with WCF ServiceRoute: Html.ActionLink rendering incorrect links!

后端 未结 3 1380
天命终不由人
天命终不由人 2020-12-05 07:02

I have a WCF service that lives side-by-side with an MVC2 web site. I\'d like for my URL for the service to look like this:

http://localhost/projdir/Service

3条回答
  •  孤街浪徒
    2020-12-05 07:58

    I resolved with that:

         routes.MapRoute(
                 "Default", // Route name
                 "{controller}/{action}/{id}", // URL with parameters
                 new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                 new { controller = "^(?!api).*" }
            );
            routes.Add(new ServiceRoute("api", new DataServiceHostFactory(), typeof(dwService)));
    

    I hope this good for you

提交回复
热议问题