Include option to allow/disallow redirects

Apr 21, 2009 at 7:16 PM
One thing you might want to consider is adding an option to allow following redirects during the check.  Sometimes when a site fails there is a redirect that would send the request to an error handle page and this could mistakenly cause WebMonitor to believe the site is still up and working fine.  So the option to allow/disallow redirect following would be helpful.
Apr 21, 2009 at 7:27 PM
Good idea, do you have an idea of how to check for this? Just from the top of my head I don't have the solution for this, so i you know it right away I would be glad to hear :)
Apr 22, 2009 at 12:36 AM
Sure, not really too difficult...

Somewhere in the URL rule you would want to add an option to enable/disable redirects and then a property in the code to handle that setting:
rules.AllowRedirects = true 
Then in your code you would need to add the following to your web request code:

if (!this.rules.AllowRedirects)
    request.AllowAutoRedirect = false;

Finally you would want to query the status code to determine if you received a System.Net.HttpStatusCode of 3xx (Usual Redirect flags).  It might be better to just trap for any System.Net.HttpStatusCodes that are other than 200 (OK)...
if (myHttpWebResponse.StatusCode != HttpStatusCode.OK)
    throw new WebException(myHttpWebResponse.StatusDescription);
That would be my first stab at the proposed change...
Apr 22, 2009 at 6:28 PM
Feature added as of April 22nd, 2009.