Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Web API in IE

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?

like image 641
Justin Avatar asked Mar 09 '12 17:03

Justin


People also ask

Can we use Web API with ASP NET web form?

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.

How do I test REST API in IE?

Use the F12 tool whenever you need to debug or test your Web API service or any client calling your Web API service.

What is ASP Net Web API?

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.

What is difference between REST API and Web API?

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.


1 Answers

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.

like image 127
Antony Scott Avatar answered Oct 27 '22 11:10

Antony Scott