0

I have the following problem there are web site that does redirection to another websites and then to another website sites.....(like a 20 redirection), I read that the object HttpWebRequest has the property MaximumAutomaticRedirections, I set this property to 10 times and check with a web site that do redirection in the Javascrip like(Client Side):

<script>
window.location = "http://www.anotherwebsite.com";
</script>

I see that I redirect all the time, I was wandering if can can set a number of re directions I want to allow, currently my code is not working.

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(myURLl);
request.MaximumAutomaticRedirections = redirectionTimes;
response = (HttpWebResponse)request.GetResponse();

I see that doesn't matter how many redirection the website does, I allow all of them? Is possible to allow only a specif numer if the re directions are done in the Client Side
Thanks

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by sknake
0

That doesn't make any sense. All of the redirections are done client side. The server sends an HTTP 301/302, uses a meta refresh, or various other methods to redirect.

Unfortunately for you the HTTPWebRequest doesn't respect all redirections that a browser might as it is not script-aware, it will fetch the data and listen for HTTP Codes (like 301/302 redirects) but not java redirects. You need to test the content you are about to server before you embed is my only suggestion.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.