Reputation: 4594
This is my first attempt at using the asp.net web api.
I've tried running it in debug mode but I'm not sure what to browse to. Can I just drop a url in my browser or do I have to create a special http get request with fancy headers or something? I just want to see that my web api controller is returning a list of stuff when I browse to it.
Any help/guidance is appreciated.
Note: I'm not using MVC, it's just an empty web application with a web api controller class added to it.
Upvotes: 0
Views: 2047
Reputation: 4594
I needed to add the following usings to my global.asax file
using System.Web.Routing;
using System.Web.Http;
and then add:
protected void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.MapHttpRoute(
name: "API Default",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
Thanks marco709394 for pointing me in the right direction and Habib for making the sensible suggestion to just create a new web api project - but unfortunately I'm required to add web api to an existing asp.net 4.0 web application.
Upvotes: 1
Reputation: 41
You can just simply browse to the url corresponding to your controller for a get request
Upvotes: 0