I have a WebApi controller with a method that looks like such:
[HttpGet] [AcceptVerbs("GET")] public HttpResponseMessage Run(string reportName, int someId, string someText, DateTime asOfDate, string username)
I have a custom route configured specifically for this action. When I navigate my browser to the web service, everything works fine, and the appropriate action is executed:
http://localhost:xxxx/ControllerName/Run/asdf/1/asdf/07-01-2012/[email protected]
However, when I attempt to programatically call the web service using the HttpClient and executing a "Get" I get a 404 error. I don't get an error when the username parameter is not an email address. For example, when the username is just "user" everything works fine. Here is the sample code:
var url = "http://localhost:xxxx/ControllerName/Run/asdf/1/asdf/07-01-2012/[email protected]" var client = new System.Net.Http.HttpClient(); var response = client.Get(url); //fails here with 404 error response.EnsureSuccessStatusCode();
I have tried UrlEncoding the email address with no luck. Any advice is appreciated.
Just a quick thought... could the ".com" be causing the issue?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With