Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

ERR_TOO_MANY_REDIRECTS after recommended URL rewrite config #10462


User avatar
0
sms.environmental created

  • What is your product version? - 10.0.0
  • What is your product type (Angular or MVC)? ASP.NET Core Backend & Angular UI
  • What is product framework type (.net framework or .net core)? .net core

Hi ASP Zero team,

We applied the required URL rewrite rules (please see the screenshot) as outlined in the documentation however we end up in an infinite redirect loop.

Would you be able to advice on this please?

Many thanks, SMS Environmental Dev Team


10 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @sms.environmental,

    Could you share what you want to achieve using these rewrite rules ? Maybe we can offer you a different solution.

  • User Avatar
    0
    sms.environmental created

    Hi @ismcagdas,

    Thank you for your response. We are following the deployment documnation available on your website. We are trying to overcome the Angular refresh issue. This is what the documentation on your website suggests: "If you refresh a page (F5) then IIS will handle the request and will not find the requested path and returns a HTTP 404 error. We should configure IIS to redirect all requests to the index.html page (or, to the root path). At the same time, IIS needs to install the URL Rewrite module, please refer to https://www.iis.net/downloads/microsoft/url-rewrite"

    We tried using the rules available in the web.config file in the client app folder. You can see the result from the screenshot above. We also tried redirecting to index.html but that didn't work too.

    We look forward to hearing from you.

    Thanks, SMS Env Dev team

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Thank you for sharing the details. For refresh problem, you only need to define 1 rewrite rule as defined in the web.config here. Have you tried this ? As I can see, the problem you are having is caused because you have two rewrite rules and they try to redirect to each other.

  • User Avatar
    0
    sms.environmental created

    Hi ismcagdas,

    Thank you for your reply. We have tried copying this web.config file and using just one rewrite rule however we get the same result. It goes intoa an infinite redirect loop. index.html redirects to index.html. If we remove this rule the app runs fine but when you refresh it goes to 404

    We haven't changed anything on the base project. The Angular routing is just like it's in the base ASPNET Zero repository. Is there anything else you would recommoned we should try ?

    Thanks, SMS Environmental Dev Team

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    In that case, could you share your app's public URL with [email protected] ? We can take a look at it and try to understand the problem.

    Thanks,

  • User Avatar
    0
    sms.environmental created

    Hi ismcagdas,

    Thank you for offering to look further into this.

    The public URL of the app is https://opuz.co.uk/

    Thanks, SMS Environmental Dev Team

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Thanks for sharing the URL. Do you host server side Host application and Angular application under the same website ? If not, can we arrange a meeting to take a look at this problem on your server ?

  • User Avatar
    0
    sms.environmental created

    Hi ismcagdas,

    I hope you had a good weekend. We host the aspnet core app and the Angular app under the same website on IIS. To deploy the application we have followed the instructions outlined on your website. Please note that we have been running older version of the Zero project for a few years and we didn't have such a problem with it.

    Arranging a meeting would be greatly appriciated. We are available any day this week. Just let us know what day and time works best for you.

    Thanks, SMS Environmental Dev Team

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @sms.environmental

    We will re-check this on our side and inform you for the meeting if we can't find the problem.

    Thanks,

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @sms.environmental

    Sorry for the delay. Did you downloaded Merged solution for your project ? If so, your Startup.cs for the Host project should contain a custom middleware code which redirects all 404 requests to index.html of the Angular project.

    In that case, you will not need a rewrite rule in your web.cofig. This is the web.config we are using for our live demo.

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.webServer>
        <handlers>
          <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
        </handlers>
        <aspNetCore processPath="dotnet" arguments=".\AspNetZeroDemo.Web.Host.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" startupTimeLimit="3600" requestTimeout="23:00:00" hostingModel="InProcess">
          <environmentVariables>
            <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />
            <environmentVariable name="COMPLUS_ForceENC" value="1" />
          </environmentVariables>
        </aspNetCore>
        <httpProtocol>
          <customHeaders>
            <remove name="X-Powered-By" />
          </customHeaders>
        </httpProtocol>
      </system.webServer>
    </configuration>
    

    Could you try like this ?