I am hosting a WCF service in an MVC3 web application. I have a method setup with a WebGet attribute with a UriTemplate. When the UriTemplate contains a period, I get a 404 response from the web server.
[OperationContract, WebGet(UriTemplate = "DoSomething")]
Stream DoWork();
http://localhost/Services/Service1.svc/DoSomething - Works Correctly
[OperationContract, WebGet(UriTemplate = "dummyfile.xml")]
Stream DoWork();
http://localhost/Services/Service1.svc/dummyfile.xml - Returns a 404 error
I am guessing it has to do with routes, but I am not sure. The routes I have setup right now are:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.svc/{*pathInfo}");
routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });
Can anyone provide some insight into how I can host a WCF service in a MVC3 app using a URITemplate with a period in it?
At the risk of plagiarism 🙂 Phil Haack has the answer