locked
WebClient get redirect uri? RRS feed

  • General discussion

  • Hi

    I am using a webclient and passing it a url to which it will redirect to a new url I need to get this new url value however i cannot seem to find a way to get this new value in my on completed event. is there a way to get this value?


    thank you
    Thursday, February 2, 2012 8:24 PM

All replies

  • Is the URL you are getting redirected to your own website or a 3rd party?
    Thursday, February 2, 2012 8:35 PM
  • Is the URL you are getting redirected to your own website or a 3rd party?
    it is a skydrive url so it would not be my website..
    Thursday, February 2, 2012 9:00 PM
  • There doesn't seem to be a way to do this natively.
    Friday, February 3, 2012 6:06 AM
  • You can try to use a HttpWebRequest.

    This is pseudo metod in Model class

    public void GetRedirectUrl(Action<WebResponse> callback, string url)
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        var n = Observable.FromAsyncPattern<WebResponse>(request.BeginGetResponse, request.EndGetResponse)();
        n.Subscribe(callback);
    }

    in VM you you can do something like this

    _model.GetRedirectUrl(((a) =>
        {
            var yourNewUrl = a.ResponseUri.AbsoluteUri;
            );
        }), "http://url.com/");




    Friday, February 3, 2012 8:55 AM