I created an application in ASP.NET 5. For the moment I'm just trying to expose a very simple Web.API method to try to get this to work. The Controller looks like this:
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc;
namespace Api
{
[Route("api/[controller]")]
public class ValuesController : Controller
{
[HttpGet("{id}")]
public async Task<Value> Get(int id)
{
return await Task.Factory.StartNew(() => new Value { Id = id });
}
}
}
I tried to follow both tutorials provided in the asp.net documentation here and here.
I have published my website to a location on my machine and have setup IIS to point to it. I have enabled the IIS logging. When I try to browse from IIS and go to the url http://localhost/TestApi/api/Values/1, I get a 404 response in the browser. It is interesting to me as well because in the ResponseHeaders I have one that looks like this: Server: Kestrel. Shouldn't this be IIS?
I also get a log file in my logs directory and it looks like this:
Hosting environment: Production
Now listening on:http://localhost:20488
Application started. Press Ctrl+C to shut down.
When I go to http://localhost:20488/api/Values/1 though, I get my JSON object returned. { Id: 1 }
I can't figure out what I'm doing wrong. I've searched a lot to try to find out what the proper configuration is to get this to work with IIS and still haven't found the answer.
Any idea what I'm doing wrong or how I can get this to work as expected?
I have reviewed these blog posts as well which seem to be great resources, but don't have any information on the problem I'm having: strathweb, blogs.msdn
UPDATE: I tried this on Windows 10 with IIS 10 and am experiencing the same issue, so I removed the IIS 7.5 from the Title of the question as it doesn't seem to be IIS 7.5 specific.