The following is WORKING on my test web server (IIS 7 on Windows 7):
But the exact same code gives me the following 404 error on both production web servers:
(IIS 7 on Windows Server 2008 AND IIS 6 on Windows Server 2003)
[The Code]
Global.asax routing setup:
protected void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{deptId}/{member}",
defaults: new { deptId = RouteParameter.Optional, member = RouteParameter.Optional}
);
}
Page.aspx jQuery statement:
$.ajax(
{
url: "api/Department/" + '<%= Request.QueryString["deptId"] %>',
contentType: "application/json",
dataType: "json",
success: function (data) {
alert('hello');
}
});
DepartmentController.cs GET method:
[HttpGet]
public Department GetDepartment(int deptId)
{
var deptRepo = new DepartmentRepository();
return deptRepo.GetDepartment(deptId);
}
I browsed a lot of similar questions on here but didn't find an answer to this.
Why would the same code work on one web server but not on others?
Is there something special I need to configure in my application or IIS?
I am really stuck on this. Any help would be greatly appreciated.