atifaltaf atifaltaf - 1 year ago 82
ASP.NET (C#) Question

WebApi is not Working in ASP.Net

I am New in Asp.Net and tried to develop a small Web API in learning process.


name: "DefaultApi",
routeTemplate: "api/v1/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }


namespace MessageBoard.Controllers
public class TopicsController : ApiController
private IMessageBoardRepository _repo;

public TopicsController(IMessageBoardRepository repo)
_repo = repo;
public IEnumerable<Topic> Get()

var topics = _repo.GetTopics()
.OrderByDescending(t => t.Created)
return topics;

Actually i am watching PluralSight tutorials.


this Url is not working in Browser not in Fiddler 4.

all references are added. i have also done Build Solution but its not working and their is no error showing in the code.

Answer Source

One last step to enable Web Api which looks like you're missing is enabling Web API in the Global.asax file by adding the following line of code to the Application_Start() method:


Also, please don't use the port number from the PluralSight tutorial.You need to run the web application project from your instance of Visual Studio and when it opens up in the browser you will see which port is assigned to YOUR api service.So if you see that it assigned port 12345 for example you would call the following URL to access the service action:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download