C# Azure移动服务-自定义API在本地运行,但部署到Azure时获得404
我已经创建了一个基于.NETWebAPI的Azure移动服务,它已经运行了一段时间,表工作正常-返回数据如预期的那样 我最近添加了一个自定义API控制器C# Azure移动服务-自定义API在本地运行,但部署到Azure时获得404,c#,api,azure,asp.net-web-api2,azure-mobile-services,C#,Api,Azure,Asp.net Web Api2,Azure Mobile Services,我已经创建了一个基于.NETWebAPI的Azure移动服务,它已经运行了一段时间,表工作正常-返回数据如预期的那样 我最近添加了一个自定义API控制器 public class FitbitWebApiController : ApiController { public ApiServices Services { get; set; } // GET api/FitbitWebApi public string Get() { Servic
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日志时,我得到以下错误消息
详细错误信息:
模块uuu DynamicModule_umicrosoft.Owin.Host.SystemWeb.OwinHttpModule,Microsoft.Owin.Host.SystemWeb,版本=3.0.0.0,区域性=中性,PublicKeyToken=31bf3856ad364e35_2ded9ca3-2357-42a5-8002-51c7cdf0ab1c
通知MapRequestHandler
处理程序扩展无UrlHandler-Integrated-4.0
错误代码0x00000000
请求的URL
不知道怎么做,但现在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>
HTTP错误404.0-找不到
您正在查找的资源已被删除、名称已更改或暂时不可用。
最可能的原因:
- 指定的目录或文件在Web服务器上不存在。
- URL包含印刷错误。
- 自定义筛选器或模块(如URLScan)限制对文件的访问。
您可以尝试的事情:
- 在Web服务器上创建内容。
- 查看浏览器URL。
- 创建跟踪规则以跟踪此HTTP状态代码的失败请求,并查看哪个模块正在调用SetStatus。有关为失败请求创建跟踪规则的详细信息,请单击
详细错误信息:
模块uuu DynamicModule_umicrosoft.Owin.Host.SystemWeb.OwinHttpModule,Microsoft.Owin.Host.SystemWeb,版本=3.0.0.0,区域性=中性,PublicKeyToken=31bf3856ad364e35_2ded9ca3-2357-42a5-8002-51c7cdf0ab1c
通知MapRequestHandler
处理程序扩展无UrlHandler-Integrated-4.0
错误代码0x00000000
请求的URLhttps://mobl_m_pedgservice:80/api/Fitbit
物理路径C:\Program Files(x86)\SiteExtensions\MobileServicesDotNet\1.0.478\api\Fitbit
匿名登录方法
匿名登录用户
更多信息:
此错误表示服务器上不存在该文件或目录。创建文件或目录,然后重试请求。
Microsoft知识库文章:
我今天再次查看了Azure门户上的日志,发现以下错误:
HttpStatus 405
HttpReason Method Not Allowed
这使我得出以下答案:
我修改了web配置以包括:
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
</system.webServer>
这就解决了这个问题——API现在正按预期被调用 我今天再次查看了Azure门户上的日志,发现以下错误:
HttpStatus 405
HttpReason Method Not Allowed
这使我得出以下答案:
我修改了web配置以包括:
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
</system.webServer>
这就解决了这个问题——API现在正按预期被调用 “mobl_m_”可能只是Azure所做的内部映射的一部分。您在日志中看到了其他错误信息吗?另外--您的其他端点是否已损坏,还是仅此一个?所有的表控制器都工作正常。azure中的完整错误已经被添加了更多问题:您是否有其他APIController?它们有用吗?您是否在WebApiConfig.cs中进行自定义设置?如果是这样,你能分享吗?没有其他API控制器和标准WebAPIConfigth“mobl_________________________________。您在日志中看到了其他错误信息吗?另外--您的其他端点是否已损坏,还是仅此一个?所有的表控制器都工作正常。azure中的完整错误已经被添加了更多问题:您是否有其他APIController?它们有用吗?您是否在WebApiConfig.cs中进行自定义设置?如果是这样,你能分享吗?没有其他API控制器和标准WebApiConfig