1

I don't understand this.

I have a webapi project setup locally on my own server, that works. I can go to http://mydomain.com/Api/Method and get my expected result no problem, works across 3g and everything too.

Then I have a website hosted somewhere else, in which tried to use this webapi method and this works fine when I test it locally, but as soon as I publish to the web and try it from there it fails with a 404 error?

I've tried both post and get methods and made sure the api method accepted both verbs.

I've tried calling the method both with javascript ajax and from within an MVC controller using a WebRequest.

I just don't understand why it works fine from any webbrowser, but I can't get it to work even with a programmatic WebRequest, shouldn't it be the same?

Mohammad Sepahvand
  • 17,364
  • 22
  • 81
  • 122
Dynde
  • 2,592
  • 4
  • 33
  • 56
  • If it doesn't work in your browser (404) it isn't going to work with a WebRequest – Jeffrey Kevin Pry Apr 27 '13 at 22:35
  • 1
    Install [fiddler](http://fiddler2.com/), see what browsers send, and try to send the same headers with WebRequest – I4V Apr 27 '13 at 22:37
  • @JeffreyKevinPry But it does work with my browser. I can visit the url to the api method without a problem. The 404 I'm getting is when I try to call the method either via jquery ajax or directly from within an MVC action using WebRequest. – Dynde Apr 27 '13 at 22:50

1 Answers1

1

Nevermind.

Apparently, it was as simple as just setting an accept header with a value of "text/html" (in my case).

I spent way too much time figuring that out. Thanks @I4V for leading me in the right direction.

Dynde
  • 2,592
  • 4
  • 33
  • 56