Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Following code from one of the thread in codeproject gives error.
"The remote server returned an error: (403) Forbidden"

file can be downloaded using download manager.

What I have tried:

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Try
Dim wc As New WebClient

Dim fileurl As String = "http://www.nseindia.com/content/historical/EQUITIES/2012/AUG/cm28AUG2012bhav.csv.zip"
Dim filelocation As String = "d:\aaaaa.zip"

wc.Headers("Accept") = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
wc.Headers("User-Agent") = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1"

wc.DownloadFile(fileurl, filelocation)

Catch exception As Exception
MsgBox("CAnnot Download")
End Try
End Sub
Posted
Updated 6-Apr-19 5:03am
Comments
Ravi Bhavnani 6-Apr-19 18:33pm    
Are you able to download this resource by browsing the NSE website?

/ravi
kunaljvyas 27-Apr-19 21:41pm    
yes , browser and download manager same link(url) is working
Ravi Bhavnani 28-Apr-19 13:20pm    
Use Fiddler to see if other headers need to be sent.

/ravi

1 solution

Do what the message tells you. Or contact the site administrators for help.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900