I create a simple Asp.net web api app. It works when running in Visual studio. The url is http://localhost:63082/api/products/1507 when debugging in Visual studio 2013.
I created an IIS website (mySite with port 8081) on a server and publish it using file sharing. However, I always get 404 error when trying the following url on the server.
http://localhost:8081/api/products/1507 (it shows the physical path is c:\inetpub\wwwroot\mySite\api\products\1507 in the error page).
http://localhost:8081/mySite/api/products/1507 (it shows the physical path is c:\inetpub\wwwroot\mySite\mySite\api\products\1507).
Why the url is not working?
The controller method.
[Route("api/Products/{fileId}")]
public IEnumerable<Product> GetProductsByFileId(int fileId)
{
using (var db = new ProductContext())
{
var query = from b in db.Products where b.fileId == fileId select b;
if (query == null)
{
return null;
}
return query.ToList();
}
}
The following shows all the published files. It seems there is no binary for the app? Is it a problem of Visual studio publishing?
Directory: \\......\c$\inetpub\wwwroot\mySite Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 7/6/2015 6:21 PM bin -a--- 7/6/2015 11:23 AM 101 Global.asax -a--- 7/6/2015 4:50 PM 574 packages.config -a--- 7/6/2015 5:41 PM 4611 Web.config Directory: \\......\c$\inetpub\wwwroot\mySite\bin Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 7/6/2015 3:11 PM 5185232 EntityFramework.dll -a--- 7/6/2015 3:11 PM 599760 EntityFramework.SqlServer.dll -a--- 7/6/2015 11:21 AM 502272 Newtonsoft.Json.dll -a--- 7/6/2015 11:21 AM 185032 System.Net.Http.Formatting.dll -a--- 7/6/2015 11:21 AM 471240 System.Web.Http.dll -a--- 7/6/2015 11:21 AM 82120 System.Web.Http.WebHost.dll -a--- 7/6/2015 5:41 PM 109056 webapi.dll