WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

System_Net
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get Redirected URL

 Keywords: Get Redirected Forward URL Link ResponseUri System.Net.WebRequest

;***************************************************************************
;**   Resolving URL from a forwarding link
;**
;** Purpose: Gets url of forwarded link
;** Inputs:
;** Outputs: Results in a Message
;** Reference:
;**       REQUIRES WinBatch 2013A or newer
;**
;** Developer: Deana Falk 2013.05.22
;***************************************************************************
If Version( )< '2013A'
   Pause('Notice', 'Need 2013A or Newer Version of WinBatch')
   Exit
EndIf

fLink = 'http://www.winbatch.com' ;forwarding link

ObjectClrOption("use","System.Net, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL")
WebRequest = ObjectClrNew('System.Net.WebRequest')
WebRequest = WebRequest.Create(fLink)
WebRequest.Timeout = WebRequest.Timeout * 6   ; Set the 'Timeout' property in Milliseconds.
WebResponse = WebRequest.GetResponse()
; The ResponseUri property contains the URI of the Internet resource that actually provided the response data.
; This resource might not be the originally requested URI if the underlying protocol allows redirection of the request.
Pause( "Results", "Forwarding Link = ":fLink:@CRLF:"Resolved URL = ": WebResponse.ResponseUri.ToString() )
Exit

Article ID:   W17834
Filename:   Get Redirected URL.txt
File Created: 2020:07:17:09:10:38
Last Updated: 2020:07:17:09:10:38