I'm struggling to get this WebAPI to work. Well, work with IIS. Everything works fine in IIS express, but when I publish it, specifically 1 api request doesn't work. I'm trying to access a url of API/[Controller]/{date}/{integer}
. I keep getting the 500 server error. My other route of API/[Controller]/{date}
works.
Here's my API Controller:
[Route("api/[controller]")] public class PostingsController : Controller { // GET: api/Postings/5 [HttpGet("{date}")] public string Get(string date) { return date; } // GET api/Postings/20160407/2 [HttpGet("{date}/{modeID}")] public List<TruckPosting> Get(string date, int modeID) { TruckPosting tp = new TruckPosting(); List<TruckPosting> truckPostings = tp.GetTruckPostings(date, modeID); return truckPostings; } }
Could the reason be that I'm trying to return a List<>? I'm stumped considering it works fine in VS's IIS Express.
Edit
Here's my startup.cs page:
public void ConfigureServices(IServiceCollection services) { services.AddMvc(); } public void Configure1(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { app.UseIISPlatformHandler(); app.UseDefaultFiles(); app.UseStaticFiles(); app.UseFileServer(true); app.UseMvc(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { app.Map("/appRoot", (app1) => this.Configure1(app1, env, loggerFactory)); }