Hi,
I want to download the document from below mentioned URL. When i try to download directly in the IE URL, it will be asking username and password credential to open the document.
But, when i try to download through application i am getting below error.
"The remote server returned an error: (401) Unauthorized."
ASP.NET Code:
downloadbutton_click event
URIFile = http:
Dim client As New WebClient()
client.Credentials = CredentialCache.DefaultCredentials
client.UseDefaultCredentials = True
client.Credentials = New NetworkCredential("XXXXXX", "XXXXXXX", "vrmnet.vrm.intranet")
Dim buffer As Byte() = client.DownloadData(URIFile )
Dim download As String = Encoding.ASCII.GetString(buffer)
Console.WriteLine(download)
Console.WriteLine("Download successful.")
Response.ContentType = "application/pdf"
Response.AddHeader("content-length", buffer.Length.ToString())
Response.BinaryWrite(buffer)
The above code is not working when i click the download button using above code. Error : "The remote server returned an error: (401) Unauthorized."
How to download the file..?
What I have tried:
URIFile = http://sr1250kl.vrmnet.vrm.intranet/A1/servlet/Download?auth=basic&event_name=k1_view&_file=emparea&id=0000008763&version=01
Dim client As New WebClient()
client.Credentials = CredentialCache.DefaultCredentials
client.UseDefaultCredentials = True
client.Credentials = New NetworkCredential("XXXXXX", "XXXXXXX", "vrmnet.vrm.intranet")
Dim buffer As Byte() = client.DownloadData(URIFile )
Dim download As String = Encoding.ASCII.GetString(buffer)
Console.WriteLine(download)
Console.WriteLine("Download successful.")
Response.ContentType = "application/pdf"
Response.AddHeader("content-length", buffer.Length.ToString())
Response.BinaryWrite(buffer)