Vb 2008 or 2005 dont care, Question

Discussion in 'Programming General' started by X Zero, Oct 5, 2008.

Vb 2008 or 2005 dont care, Question
  1. Unread #1 - Oct 5, 2008 at 7:02 AM
  2. X Zero
    Joined:
    Jan 21, 2007
    Posts:
    577
    Referrals:
    0
    Sythe Gold:
    0

    X Zero Forum Addict

    Vb 2008 or 2005 dont care, Question

    NEW QUESTION

    Any idea Why

    Code:
    WebClient.DownloadFileAsync
    Doesnt work in vista, but it does in xp?

    Code:
    WebClient.DownloadFile
    Works in both but I don't want to block the thread


    ______

    Old Question





    Dont know what to call it but ill explain what im trying to do and its probs easy but yeah.


    I have a URL(a) and it redirects to another URL(b).

    How could I get url(B) with out using a web browser if possible?

    And Url(b) Changes.

    I have tried using Net.Webclient but sort of failed. Any help would be wonderful
     
  3. Unread #2 - Oct 5, 2008 at 5:21 PM
  4. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Vb 2008 or 2005 dont care, Question

    If the redirect code is in the page itself, you could always find it and parse it by downloading the page with WebClient. Otherwise, you could do a cheap job and make an invisible webbrowser, navigate and get the url from it. Just set the visible property to false.
     
  5. Unread #3 - Oct 5, 2008 at 7:26 PM
  6. Flaming Idiots
    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User

    Flaming Idiots Active Member
    Visual Basic Programmers

    Vb 2008 or 2005 dont care, Question

    You can use a web request to check for redirection headers. This works for things like Tiny URL, but not JavaScript redirection.

    Code:
    Public Function GetRedirectionUrl(ByVal Url As String) As String
        Dim Request = TryCast(Net.WebRequest.Create(Url), Net.HttpWebRequest)
        If Request Is Nothing Then Return Nothing
        Request.AllowAutoRedirect = False
        Return Request.GetResponse.Headers("Location")
    End Function
     
  7. Unread #4 - Oct 5, 2008 at 10:45 PM
  8. X Zero
    Joined:
    Jan 21, 2007
    Posts:
    577
    Referrals:
    0
    Sythe Gold:
    0

    X Zero Forum Addict

    Vb 2008 or 2005 dont care, Question

    Thanks swan and flaming idiots

    I didnt really wanna use the invisible web browser, it seemed tacky and unreliable.

    But that GetRedirectionUrl function works like a charm, ur a genius

    NEW QUESTION SEE FIRST POST
     
< Crack Me (Testing weird password thing) Please Help | Java Math Kit V1 - Vinny >

Users viewing this thread
1 guest


 
 
Adblock breaks this site