我有同樣的問題,按照下列問題,並試圖回答,但從來沒有解決問題的Web API調用本地而不是工作在Azure上
Web api interface works locally but not on Azure
Web API interface works locally but gets 404 after deployed to Azure Website
和許多相似類型的...
,當我試圖調用API,它說404未找到
我WebApi.config文件
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "versionApi",
routeTemplate: "api/{version}/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
API控制器
[Authorize]
[RequiresSSL]
[RoutePrefix("api/v2/Configuration")]
public class ConfigurationAPIv2Controller : ApiController
{
[Dependency]
public IConfigurationServicev2 configurationService { get; set; }
[Dependency]
public IAccountService accountService { get; set; }
#region testapi
[Route("getstring")]
[HttpGet]
public IHttpActionResult getstring()
{
return Ok("Success");
}
[Route("putstring")]
[HttpPut]
public IHttpActionResult putstring()
{
return Ok("Success");
}
#endregion
和文件夾結構是這樣的:
即使我嘗試刪除[Authorize]和[RequiresSSL]屬性 –