Web Connection
Multiple Hits caused by URL Rewrite
Gravatar is a globally recognized avatar based on your email address. Multiple Hits caused by URL Rewrite
  Harvey Mushman
  All
  Jan 31, 2017 @ 10:19am

I got bitten by URL Rewrite... it took a while to figure out what was going on. Fiddler helpped find the problem by color highlighting dead URL's to photos on my page.

In my AngularJS application, I have all the pages addressed without a file extention. This is very normal for these apps with a element tag for base="/". This all has to do with angular removing the hash symbol from the url as well.

Anyway for this to all work correctly, it is suggested that URL Rewrite is used to redirect unknown requests to the default page at the site root. This has been working great and even if a user presses the refresh button on their browser after drilling down four or file pages, the rewrite rule forces them back to the correct starting point - the default page without throwing an error.

So the problem I was seeing on the WC server existed every time I would navigate to a page that had a bunch of broken photo links. I guess on my localhost machine I forgot to copy all the current images that are in my table of photos.

Here is my old rewrite rules.

<rewrite>
<rules>
<clear />
<rule name="Angular Default Route" 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}" pattern="/*.wcs" negate="true" />
</conditions>
<action type="Rewrite" url="/" appendQueryString="false" />
</rule>
</rules>
</rewrite>    


Here is the rule I had to add to fix the problem.

<rule name="Don't Redirect Missing Images or CSS" stopProcessing="true">
<match url="\.png|\.css|\.jpg|\.gif" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="None" />
</rule>

The new rule must be listed as the first rule for this to work but the idea is very simple, missing photo files do not get redirected to the default home page. Problem solved!

Hope this helps, it sure had me wondering for several hours what might be causing an extra fifteen hits to default every time I loaded the problem page!

Gravatar is a globally recognized avatar based on your email address. re: Multiple Hits caused by URL Rewrite
  Rick Strahl
  Harvey Mushman
  Jan 31, 2017 @ 03:12pm

Yes you have to be careful with URLRewrite to try and focus it as much as possible - otherwise you can get nasty surprises especially if you're routing to FoxPro.

The last thing you want to have static resources routed into your FoxPro application 😃

+++ Rick ---

© 1996-2024