title: Not able to download file - The remote server returned an error: (403) Forbidden
body: <p>I'm trying to download a zip file in Windows Application , but is is throwing an error . My code is :</p>
  
  <pre><code>    string url = "https://www.nseindia.com/content/historical/DERIVATIVES/2017/JUN/fo07JUN2017bhav.csv.zip";
      using (WebClient wc = new WebClient())
      {
          wc.DownloadFile(url, @"c:\bhav\file.zip");
      }
  </code></pre>
  
  <p>Exception details :</p>
  
  <blockquote>
    <p>System.Net.WebException was unhandled   HResult=-2146233079<br>
    Message=The remote server returned an error: (403) Forbidden.<br>
    Source=System   StackTrace:
           at System.Net.WebClient.DownloadFile(Uri address, String fileName)
           at System.Net.WebClient.DownloadFile(String address, String fileName)
           at unzip.Form1.downloadFile() in c:\users\ethicpro\documents\visual studio
    2015\Projects\unzip\unzip\Form1.cs:line 30
           at unzip.Form1..ctor() in c:\users\ethicpro\documents\visual studio 2015\Projects\unzip\unzip\Form1.cs:line 20
           at unzip.Program.Main() in c:\users\ethicpro\documents\visual studio 2015\Projects\unzip\unzip\Program.cs:line 19
           at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
           at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
           at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
           at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
           at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext
    activationContext, String[] activationCustomData)
           at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext
    activationContext)
           at System.Activator.CreateInstance(ActivationContext activationContext)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.RunInternal(ExecutionContext
    executionContext, ContextCallback callback, Object state, Boolean
    preserveSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean
    preserveSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()   InnerException:</p>
  </blockquote>
  
  <p>Link is : <a href="https://www.nseindia.com/content/historical/DERIVATIVES/2017/JUN/fo07JUN2017bhav.csv.zip" rel="nofollow noreferrer">https://www.nseindia.com/content/historical/DERIVATIVES/2017/JUN/fo07JUN2017bhav.csv.zip</a></p>
  
  <p>I searched for other questions but didn't get the proper answer.</p>