I have a page that redirects to a video (.3gp). The problem (from what i can tell) is that after begining the request from the original page, i get a very late response. I suppose this is because the web request waits for the data to download. Here is my code :
System.Uri targetUri = new System.Uri(TextBlockTargetUri.Text);
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(targetUri);
request.AllowReadStreamBuffering = true;
request.AllowAutoRedirect = true;
request.BeginGetResponse(new AsyncCallback(ReadWebRequestCallback), request);
private void ReadWebRequestCallback(IAsyncResult callbackResult)
{
HttpWebRequest myRequest = (HttpWebRequest)callbackResult.AsyncState;
HttpWebResponse myResponse = (HttpWebResponse)myRequest.EndGetResponse(callbackResult);
using (StreamReader httpwebStreamReader = new StreamReader(myResponse.GetResponseStream()))
{
string stuff2 = myResponse.ResponseUri.AbsoluteUri;
Dispatcher.BeginInvoke(() => TextBlockResults.Text = stuff2);
}
myResponse.Close();
}
I only need the url, because the player i am using has a streaming method of its one, so i shouldn’t wait for the entire video to download. How can i get only the redirect url and not wait for the video?
You can use the
HEADhttp method, just do:This method asks the server to return only the headers