Resolving "The Resource You Are Looking For Has Been Removed" Error in Azure Web Apps: In-depth Analysis and Configuration Guide

Nov 25, 2025 · Programming · 9 views · 7.8

Keywords: Azure | ASP.NET WebAPI | URL Rewrite

Abstract: This article addresses the common error "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable" when deploying ASP.NET WebAPI or MVC applications to Azure Web Apps, particularly for non-default routes. Based on Q&A data and reference articles, it focuses on SPA configuration needs, explains URL rewrite rules in web.config, and supplements with static content MIME type settings. Through code examples and step-by-step guidance, it helps developers understand error causes and implement effective solutions for stable application performance in Azure environments.

Problem Background and Error Analysis

When deploying ASP.NET WebAPI or MVC applications to Azure Web App Services, many developers encounter a common issue: the default page loads correctly, but accessing other links or routes results in an error message: "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable." This error typically indicates that the server fails to handle client requests properly, especially in single-page application (SPA) or dynamic routing scenarios. It often stems from improper IIS configuration, causing requests not to be routed correctly to the application's entry point, such as index.html.

Core Solution: web.config File Configuration

According to the best answer in the Q&A data (Answer 3), the key to resolving this issue is adding a web.config file to the Azure deployment directory and configuring URL rewrite rules. This ensures that all non-file and non-directory requests are redirected to the application's root path, supporting SPA routing mechanisms. Below is a detailed web.config configuration example, optimized and explained based on supplementary content from Answer 1.

First, create a web.config file and add the following code. This configuration uses the IIS URL Rewrite module to rewrite all requests to the root URL, unless the request is for an actual file or directory. This helps handle client-side routing and prevent 404 errors.

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Main Rule" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="/" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

In this configuration, the <rule> element defines a rule with the name attribute set to "Main Rule" and stopProcessing set to true, meaning if this rule matches, subsequent rules are not processed. <match url=".*" /> matches all URL patterns. The <conditions> section uses logical grouping "MatchAll" to ensure both conditions are met: the request is not a file (negated IsFile) and not a directory (negated IsDirectory). If conditions hold, the <action> rewrites the request to the root URL (/), allowing the application to handle routing.

Supplementary Configuration: MIME Type Settings

Answer 2 provides a solution for another potential issue: if the application involves static files (e.g., JSON, font files), configuring MIME types may be necessary to avoid server errors. For instance, adding the following code to the <staticContent> section in web.config ensures that files like .woff2, .woff, and .json are correctly recognized and served.

<system.webServer>
  <staticContent>
    <mimeMap fileExtension=".woff2" mimeType="application/x-font-woff" />
    <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
    <mimeMap fileExtension=".json" mimeType="application/json" />
  </staticContent>
</system.webServer>

This addresses resource loading failures due to missing MIME types, further enhancing application compatibility.

In-depth Analysis and Best Practices

The reference article (Article 1) highlights using PM2 with the --spa argument for Angular SPA deployment, but this may not be directly applicable in Azure Web App Services, which typically rely on IIS configuration. Thus, the web.config approach is more universal. Developers should ensure the web.config file is in the application's root directory and test configurations before deployment. Additionally, for complex applications, consider using Azure App Service deployment slots for A/B testing to verify the impact of configuration changes.

In summary, by properly configuring the web.config file, developers can effectively resolve routing errors and improve application stability and user experience in Azure environments. It is recommended to use browser developer tools post-deployment to check network requests and confirm that rewrite rules are functioning as intended.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.