I am starting to use the new ASP.NET Web API. When I open a sample service method call using a browser like FF or Chrome, it returns the xml correctly in the browser. However, in Internet Explorer (7-9) it brings up a prompt:
Do you want to open or save read (58 bytes) from [servername]?
When I select Open, it asks which program to open with, and then it will display the xml in that program. I was hoping since the methods accept the GET method that it would just return the results in the browser, however that doesn't seem to be the case with IE. I have run into this sort of issue before with ASP.NET MVC when returning JSON, however I'm not even returning JSON in this case.
How do I tell IE to return the results in the browser like FF and Chrome do?
Although ASP.NET Web API is packaged with ASP.NET MVC, it is easy to add Web API to a traditional ASP.NET Web Forms application. To use Web API in a Web Forms application, there are two main steps: Add a Web API controller that derives from the ApiController class. Add a route table to the Application_Start method.
Use the F12 tool whenever you need to debug or test your Web API service or any client calling your Web API service.
ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the . NET Framework.
Web API can be hosted only on an Internet Information Service (IIS) or self that supports XML and JSON requests. In contrast, REST API can be hosted only on IIS that supports standardized XML requests.
I've noticed that too. It is actually returning the results as JSON. To view the result of the call go into the developer tools (F12), then go to Network, click start monitoring and resend your request. You should see the result appear in the trace list. You can then double click it and select View Body to see the response body.
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