Base solution for your next web application
Open Closed

Azure Redirection Issue #6761


User avatar
0
kalidarscope created

We have successfully deployed the ASP.NET Core and Angular project in Azure. Everything working fine. If i refresh the page or change the url, it shows following error:

The requested content does not exist.

    HttpStatusCode: 404
    ErrorCode: WebContentNotFound
    RequestId : 5714d6ad-301e-0006-0e4f-e9ecc1000000
    TimeStamp : 2019-04-02T12:27:49.8443130Z

Also find the screenshot:


9 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    Have you seen the tutorial on publishing Angular? https://docs.aspnetzero.com/documents/aspnet-core-angular/latest/Deployment-Angular-Publish-Azure

    What is the web.config content in your angular app?

  • User Avatar
    0
    kalidarscope created

    Where can we find the web.config file?

    I have only one file named web.config in ASAP.Web.Public.

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.webServer>
        <httpProtocol>
          <customHeaders>
            <remove name="X-Powered-By" />
          </customHeaders>
        </httpProtocol>
      </system.webServer>
    </configuration>
    
  • User Avatar
    0
    maliming created
    Support Team

    https://github.com/aspnetzero/aspnet-zero-core/blob/dev/angular/web.config#L11

    refer to:https://docs.aspnetzero.com/documents/aspnet-core-angular/latest/Deployment-Angular-Publish-Azure#publish-angularui-to-the-azure

  • User Avatar
    0
    kalidarscope created

    I have moved the web.config file from ASAP.Web.Public to ASAP.Web.Host\wwwroot\dist. But facing same issue.

    Note: We are using ASP.NET CORE & Angular (single solution). That's why we don't have web.config in angular folder.

    We have tried the following changes in web.config.

    Change 1:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.webServer>
        <handlers>
          <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
        </handlers>
        <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" startupTimeLimit="3600" requestTimeout="23:00:00">
          <environmentVariables />
        </aspNetCore>
        <httpProtocol>
          <customHeaders>
            <remove name="X-Powered-By" />
          </customHeaders>
        </httpProtocol>
      </system.webServer>
    </configuration>
    

    Change 2:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.webServer>
        <httpProtocol>
          <customHeaders>
            <remove name="X-Powered-By" />
          </customHeaders>
        </httpProtocol>
        <rewrite>
          <rules>
            <rule name="Angular Routes" stopProcessing="true">
              <match url=".*" />
              <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
              </conditions>
              <action type="Rewrite" url="/" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration>
    
  • User Avatar
    0
    maliming created
    Support Team

    Try this web.config.

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.webServer>
        <handlers>
          <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
        </handlers>
        <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" startupTimeLimit="3600" requestTimeout="23:00:00">
          <environmentVariables />
        </aspNetCore>
        <httpProtocol>
          <customHeaders>
            <remove name="X-Powered-By" />
          </customHeaders>
        </httpProtocol>
    	<staticContent>
          <remove fileExtension=".json" />
          <mimeMap fileExtension=".json" mimeType="application/json" />
    	  <mimeMap fileExtension="woff" mimeType="application/font-woff" />
          <mimeMap fileExtension="woff2" mimeType="application/font-woff" /> 
        </staticContent>
        <!-- IIS URL Rewrite for Angular routes -->
        <rewrite>
          <rules>
            <rule name="Angular Routes" stopProcessing="true">
              <match url=".*" />
              <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
              </conditions>
              <action type="Rewrite" url="/" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration>
    
  • User Avatar
    0
    kalidarscope created

    Tried. Still have same issue.

  • User Avatar
    0
    maliming created
    Support Team

    Is it convenient to share project code? Or can I take a look at it remotely? my email:[email protected]

  • User Avatar
    0
    kalidarscope created

    Mailed you the details

  • User Avatar
    0
    maliming created
    Support Team

    Solve problems remotely

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.webServer>
        <httpProtocol>
          <customHeaders>
            <remove name="X-Powered-By" />
          </customHeaders>
        </httpProtocol>
        <staticContent>
          <remove fileExtension=".json" />
          <remove fileExtension=".woff" />
          <remove fileExtension=".woff2" />
          <mimeMap fileExtension=".json" mimeType="application/json" />
          <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
          <mimeMap fileExtension=".woff2" mimeType="application/font-woff" /> 
        </staticContent>
        <rewrite>
          <rules>
            <rule name="Angular Routes" stopProcessing="true">
              <match url=".*" />
              <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
              </conditions>
              <action type="Rewrite" url="/" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration>