1

I have create a Azure Mobile service based on .net Web Api and it has been running for a while and the tables work fine - returning data as expected.

I have recently added a custom API controller

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";
    }

}

I was expecting to be able to access this API by adding /Api/FitbitWebApi to my service URL.

When I ran this locally - yes localhost:118/api/FitBitWebApi worked fine but when I deploy this to Azure I get a 404 error instead.

In fact - when I look at the azure logging I get the following error message

Detailed Error Information: Module __DynamicModule_Microsoft.Owin.Host.SystemWeb.OwinHttpModule, Microsoft.Owin.Host.SystemWeb, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35_2ded9ca3-2357-42a5-8002-51c7cdf0ab1c Notification MapRequestHandler Handler ExtensionlessUrlHandler-Integrated-4.0 Error Code 0x00000000 Requested URL http://mobl_m_pedgservice:80/api/FitbitWebApi

Not sure how but now Azure seems to have added mobl_m to the beginning of my URL

Anyone got any ideas?

The Full error trace from the Azure logs is :

<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>&nbsp;&nbsp;&nbsp;__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>&nbsp;&nbsp;&nbsp;MapRequestHandler</td></tr> 
<tr class="alt"><th>Handler</th><td>&nbsp;&nbsp;&nbsp;ExtensionlessUrlHandler-Integrated-4.0</td></tr> 
<tr><th>Error Code</th><td>&nbsp;&nbsp;&nbsp;0x00000000</td></tr> 

</table> 
</div> 
<div id="details-right"> 
<table border="0" cellpadding="0" cellspacing="0"> 
<tr class="alt"><th>Requested URL</th><td>&nbsp;&nbsp;&nbsp;https://mobl_m_pedgservice:80/api/Fitbit</td></tr> 
<tr><th>Physical Path</th><td>&nbsp;&nbsp;&nbsp;C:\Program Files (x86)\SiteExtensions\MobileServicesDotNet\1.0.478\api\Fitbit</td></tr> 
<tr class="alt"><th>Logon Method</th><td>&nbsp;&nbsp;&nbsp;Anonymous</td></tr> 
<tr><th>Logon User</th><td>&nbsp;&nbsp;&nbsp;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&amp;IIS70Error=404,0,0x00000000,9200">View more information &raquo;</a></p> 
<p>Microsoft Knowledge Base Articles:</p> 
Ashley Jackson
  • 183
  • 1
  • 1
  • 8

1 Answers1

0

I had another look at the logs on the Azure portal today and saw the following errors:

      HttpStatus    405
      HttpReason    Method Not Allowed

This lead me to the following answer : Stackoverflow - asp-net-wenapi 405 errors

I amended the web config to include :

<system.webServer>
  <modules>
    <remove name="WebDAVModule" />
  </modules>
  <handlers>
    <remove name="WebDAV" />
  </handlers>
</system.webServer>

And this fixed the issue - the API is now getting called as expected!

Community
  • 1
  • 1
Ashley Jackson
  • 183
  • 1
  • 1
  • 8