How to check whether the URLs is redirecting or not


#1

Hi,

Im trying to check the status of URL, whether the URL has redirecting or broken link. I’ve tried with HTTPs activity its give me the status of URL not the response. Example if i open “google.com” its redirecting to “https://www.google.co.in/?gfe_rd=cr&dcr=0&ei=aHyjWvyDNs3nugS8-oPwAg”. I want to get the status as 301 or 302 and the redirected link. By using HTTPS activity its give me status as 200. Any other option?


#2

Any suggestion.


#3

redirect.xaml (6.7 KB)


#4

Thanks @vvaidya,

Its working fine, but if i pass a broken link its throwing an exception.

“Message: The remote server returned an error: (404) Not Found.” If Status is 404 how to save this value to a variable.


#5

Surround the code by Try Catch and in the catch block:

1)use “System.Net.Webexception” and assign ex.Status.ToString to your Variable

2)also use “System.Exception” for other errors.

I don’t think order matters.

Thanks,

Vinay


#6

Hi,
Can you please provide us an example.


#7

Fyi…

redirect_exception.xaml (12.9 KB)


Creating Exception for a Broken URL