My case is very similar to this question, but since he did not get an answer I thought I'd throw some more input.
Everything works fine locally (on the VS embedded server). When I deploy to Azure, I get a 404 error accompanied by "No type was found that matches the controller named...".
However, when I load the routedebugger module the mapping seems ok even on Azure.
What can I do to debug that problem?
Thanks,
Alex
Edit: my routes are created this way:
GlobalConfiguration.Configuration.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
};
GlobalConfiguration.Configuration.Routes.MapHttpRoute(
name: "ActionApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
Edit 2: Here my controller class
public class EmployeeController : ApiController
{
// GET api/<controller>
public IEnumerable<Employee> Get()
{
using (var context = new nws())
{
return context.Employees;
}
}
// GET api/<controller>/5
public Employee Get(int id)
{
using (var context = new nws())
{
return context.Employees.FirstOrDefault(e => e.ID == id);
}
}
// GET api/<controller>/getbyatid/5
public Employee GetByAtId(string id)
{
using (var context = new nws())
{
return context.Employees.FirstOrDefault(e => e.AtUserID == id);
}
}
// POST api/<controller>
public void Post([FromBody]string value)
{
}
// PUT api/<controller>/5
public void Put(int id, [FromBody]string value)
{
}
// DELETE api/<controller>/5
public void Delete(int id)
{
}
// GET api/<controller>/timebank/5
public int? GetTimeBank(string id)
{
using (var context = new nws())
{
var employee = context.Employees.FirstOrDefault(e => e.AtUserID == id);
if (employee != null)
return employee.GetTimeBank();
return null;
}
}
}
Log on to your azure subscription where you have on-premise data gateway registered. Create a resource of type “Logic Apps Custom Connector”. Open a custom connector and click on edit. Choose API Endpoint as SOAP and Call mode as SOAP to REST and then browse to upload WSDL file of your on-premise webservice.
What is Web API in Azure? Azure Web API Apps, one of the Azure App Service features that offers a rich platform and ecosystem for building, consuming, and distributing APIs in the cloud and on-premises. The key accomplishments using Azure API Apps are as follows: Integrate with SaaS and enterprise applications.
Switch the order of routes and try again.
GlobalConfiguration.Configuration.Routes.MapHttpRoute(
name: "ActionApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
GlobalConfiguration.Configuration.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With