[英]Azure Mobile Service - Custom API runs locally but get 404 when Deployed to Azure
我已经创建了一个基于.net Web Api的Azure移动服务,该服务已经运行了一段时间,并且该表可以正常工作-按预期返回数据。
我最近添加了一个自定义API控制器
public class FitbitWebApiController : ApiController
{
public ApiServices Services { get; set; }
// GET api/FitbitWebApi
public string Get()
{
Services.Log.Info("Hello from custom controller!");
return "Hello Friend";
}
}
我希望能够通过将/ Api / FitbitWebApi添加到我的服务URL中来访问此API。
当我在本地运行时-是的,localhost:118 / api / FitBitWebApi工作正常,但是当我将其部署到Azure时,却收到404错误。
实际上-当我查看Azure日志记录时,收到以下错误消息
详细的错误信息:模块__DynamicModule_Microsoft.Owin.Host.SystemWeb.OwinHttpModule,Microsoft.Owin.Host.SystemWeb,版本= 3.0.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35_2ded9ca3-2357-42a5-8002-51c7cdf0ab1c通知MapRequestHandler处理程序ExtensionlessUrlHandler-In -4.0错误代码0x00000000请求的URL http:// mobl_m_pedgservice:80 / api / FitbitWebApi
不知道如何,但是现在Azure似乎已经在我的URL开头添加了mobl_m
任何人有任何想法吗?
来自Azure日志的完整错误跟踪为:
<h3>HTTP Error 404.0 - Not Found</h3>
<h4>The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.</h4>
</div>
<div class="content-container">
<fieldset><h4>Most likely causes:</h4>
<ul> <li>The directory or file specified does not exist on the Web server.</li> <li>The URL contains a typographical error.</li> <li>A custom filter or module, such as URLScan, restricts access to the file.</li> </ul>
</fieldset>
</div>
<div class="content-container">
<fieldset><h4>Things you can try:</h4>
<ul> <li>Create the content on the Web server.</li> <li>Review the browser URL.</li> <li>Create a tracing rule to track failed requests for this HTTP status code and see which module is calling SetStatus. For more information about creating a tracing rule for failed requests, click <a href="http://go.microsoft.com/fwlink/?LinkID=66439">here</a>. </li> </ul>
</fieldset>
</div>
<div class="content-container">
<fieldset><h4>Detailed Error Information:</h4>
<div id="details-left">
<table border="0" cellpadding="0" cellspacing="0">
<tr class="alt"><th>Module</th><td> __DynamicModule_Microsoft.Owin.Host.SystemWeb.OwinHttpModule, Microsoft.Owin.Host.SystemWeb, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35_2ded9ca3-2357-42a5-8002-51c7cdf0ab1c</td></tr>
<tr><th>Notification</th><td> MapRequestHandler</td></tr>
<tr class="alt"><th>Handler</th><td> ExtensionlessUrlHandler-Integrated-4.0</td></tr>
<tr><th>Error Code</th><td> 0x00000000</td></tr>
</table>
</div>
<div id="details-right">
<table border="0" cellpadding="0" cellspacing="0">
<tr class="alt"><th>Requested URL</th><td> https://mobl_m_pedgservice:80/api/Fitbit</td></tr>
<tr><th>Physical Path</th><td> C:\Program Files (x86)\SiteExtensions\MobileServicesDotNet\1.0.478\api\Fitbit</td></tr>
<tr class="alt"><th>Logon Method</th><td> Anonymous</td></tr>
<tr><th>Logon User</th><td> Anonymous</td></tr>
</table>
<div class="clear"></div>
</div>
</fieldset>
</div>
<div class="content-container">
<fieldset><h4>More Information:</h4>
This error means that the file or directory does not exist on the server. Create the file or directory and try the request again.
<p><a href="http://go.microsoft.com/fwlink/?LinkID=62293&IIS70Error=404,0,0x00000000,9200">View more information »</a></p>
<p>Microsoft Knowledge Base Articles:</p>
我又看了一眼Azure门户上的日志,看到以下错误:
HttpStatus 405
HttpReason Method Not Allowed
这将我引向以下答案: Stackoverflow-asp-net-wenapi 405错误
我修改了网络配置,使其包括:
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
</system.webServer>
这解决了这个问题-现在可以按预期调用API!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.