405 Method Not Allowed, API service in azure portal

SKR 1 Reputation point
2026-01-29T11:51:09.15+00:00

405 Method Not Allowed,

visual studio code, i have a subproject which is handling API service,

Application is working fine in my local machine, using localhost,

Issue rising only on azure portal web app,

What went wrong, what extra setup i have to do on handler or any ...?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
{count} votes

3 answers

Sort by: Most helpful
  1. Golla Venkata Pavani 1,740 Reputation points Microsoft External Staff Moderator
    2026-01-29T14:57:23.4966667+00:00

    Hi @SKR,

    Thank you for reaching us regarding the issue and very common issue when moving an ASP.NET Web API from local development (IIS Express) to Azure App Service. Your app works fine on localhost because IIS Express typically doesn't have WebDAV active or interfering, but Azure runs on full IIS where WebDAV is enabled by default and can block or conflict with certain HTTP verbs, including POST in some setup scenarios.

    This is usually fixed with a small web.config adjustment, no portal settings or code changes needed beyond that.

    Recommendation:
    Add or update the following in your project's root web.config file under the section:

    <system.webServer>
      <modules runAllManagedModulesForAllRequests="true">
        <remove name="WebDAVModule" />
      </modules>
      <handlers accessPolicy="Read, Script">
        <remove name="WebDAV" />
        <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
        <add name="ExtensionlessUrlHandler-Integrated-4.0"
             path="*."
             verb="GET,HAD,POST,PUT,DELETE,PATCH,OPTIONS"
             type="System.Web.Handlers.TransferRequestHandler"
             preCondition="integratedMode,runtimeVersionv4.0" />
      </handlers>
    </system.webServer>
    
    
    • This removes the WebDAV module/handler (the main culprit) and reconfigures the extensionless handler to explicitly support the verbs your API uses in Azure's Integrated pipeline mode.
    • Redeploy your app (e.g., via VS Code's Azure extension, Azure DevOps, or ZIP deploy).
    • After deployment, go to the Azure Portal > Your App Service > Overview > Restart to ensure the config is picked up.

    After Deploy, Quick Test :

    • Use Postman or curl: POST https://yourapp.azurewebsites.net/api/yourendpoint (with any required body/headers like Content-Type: application/json).
    • If you still see 405, inspect the response headers, the Allow header will list what methods IIS currently permits (super helpful for debugging).

    Additional Tips:

    • Confirm your controller uses [HttpPost] and the route matches perfectly (no extra/trailing slashes).
    • If this is an ASP.NET Core app (no web.config handlers needed), focus on routing in Program.cs/Startup.cs and CORS if cross-origin.
    • For more visibility: Portal > Monitoring > Log stream or enable Application logging / Failed request tracing in Diagnostic settings.

    Reference:
    https://learn.microsoft.com/en-us/aspnet/web-api/overview/testing-and-debugging/troubleshooting-http-405-errors-after-publishing-web-api-applications#what-causes-http-405-errors
    https://learn.microsoft.com/en-us/troubleshoot/developer/webapps/iis/site-behavior-performance/http-error-405-website
    https://learn.microsoft.com/en-us/azure/app-service/troubleshoot-diagnostic-logs

    Kindly let us know if the above helps or you need further assistance on this issue.

    Please "accept" if the information helped you. This will help us and others in the community as well.

    0 comments No comments

  2. SKR 1 Reputation point
    2026-01-29T11:57:24.9366667+00:00

    1.Handler Configuration : using POST method

    2.WebDAV Interference: in the webconfig file inserted following line

    <modules>

      <remove name="WebDAVModule" />
    
    </modules>
    

    <handlers>

      <remove name="WebDAV" />
    

    Routing Issues: Local machine working fine. Azure environment variables inserted web address to replace localhost

    IIS Settings: applicationhost.config where is it in visual studio code

    Firewall or Network Issues: how can i check this.

    Thanks

    0 comments No comments

  3. Q&A Assist
    2026-01-29T11:51:20.0533333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The HTTP 405 Method Not Allowed error indicates that the HTTP method being used for your API request is not allowed for the specific resource on your Azure App Service. This issue can arise when the application works locally but fails when deployed due to differences in configuration or server settings.

    Here are some potential causes and solutions:

    1. Handler Configuration: Ensure that the correct HTTP handlers are configured in your Azure App Service. If a specific HTTP method (like PUT or DELETE) is not allowed for the endpoint, you may need to adjust the handler settings in the Azure portal.
    2. WebDAV Interference: If WebDAV is enabled on your Azure App Service, it may interfere with certain HTTP methods like PUT. You can check the settings in the Azure portal to see if WebDAV is enabled and consider disabling it if it's not needed.
    3. Routing Issues: Verify that the routing for your API endpoints is correctly set up in your application. If the route does not match what is expected, it could lead to a 405 error.
    4. IIS Settings: If your application is hosted on IIS, ensure that the application’s applicationhost.config file has the correct handlers defined for the HTTP methods you intend to use. You may need to manually adjust these settings if they are not correctly configured.
    5. Firewall or Network Issues: Check if there are any firewall rules or network configurations that might be blocking certain HTTP methods from being processed correctly.

    To troubleshoot further, you can use tools like curl to test the API endpoints directly from the Azure environment to see what HTTP status codes are returned.

    By addressing these areas, you should be able to resolve the 405 Method Not Allowed error on your Azure App Service.


    References:

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.