AngularJS
IIS URL Rewrite Configutration
Gravatar is a globally recognized avatar based on your email address. IIS URL Rewrite Configutration
  Harvey Mushman
  All
  Jan 5, 2017 @ 09:05am

I think I got it figured out where I can have a rewrite back to the home page on User Refresh when the Angular Route has drilled into a page that includes data that wasderived by following a path. In other words, as a user drills down through the system they are cacheing data as they go. Then if for some unknown reason they hit the refresh button on the browers, they are returned to the current page. But at this point they don't have nor have set the data up to correctly display the current page. The solution is to return to the home page and force them to start over.

So at this point the two rules I have do the following, first enforce all hits are HTTPS. Second, if the hit is not a file, folder or a known file extension redirect them back to the home page. (In my case "callback.xyz" is a JSON hit from AngularJS application.)

    <rewrite>
      <rules>
        <clear />
        <rule name="Redirect to HTTPS" enabled="true" stopProcessing="true">
          <match url="(.*)" />
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
          <conditions>
            <add input="{HTTPS}" pattern="^OFF$" />
          </conditions>
        </rule>
        <rule name="AngualrJS Routes" enabled="true" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        <add input="{REQUEST_URI}" matchType="Pattern" pattern="(?:.xyz)|(?:.wc)|(?:.aspx)" ignoreCase="true" negate="true" />
          </conditions>
          <action type="Redirect" url="/" appendQueryString="false" />
        </rule>
      </rules>
    </rewrite>

This allows me to access the Web Connection Administration pages in addition to my application.

Any thoughts?

Gravatar is a globally recognized avatar based on your email address. re: IIS URL Rewrite Configutration
  Rick Strahl
  Harvey Mushman
  Jan 5, 2017 @ 07:06pm

That looks about right.

But - wouldn't it be easier to just look for extensionless URLs for the Angular Routes? ie. *.?

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: IIS URL Rewrite Configutration
  Harvey Mushman
  Rick Strahl
  Jan 6, 2017 @ 05:05am

Yep, that makes perfect sense, why did I not think of that...

lol

© 1996-2024