0

I have to download an Excel file from the following URL:

https://abcdef/testCopy.xlsx

I can load it into Internet Explorer using the following command:

Process.Start("IExplore.exe", "https://abcdef/testCopy.xlsx");

This works fine, but the server requests a username and password before the file will download a file.

As an added convenience I wish to also supply the server username and password if I may.

Is this possible, and if so how is it done?

WonderWorker
  • 8,539
  • 4
  • 63
  • 74
Shreya
  • 1
  • 1
  • Depends on how it asks for a username and password.. sometimes you can do `http://username:password@host/path/file` and often you cant.. – BugFinder Jun 27 '19 at 11:08
  • It does not works by passing the credentials in URL . I have to input the username and password. What i need is if I can write them through code in the respective text boxes. – Shreya Jun 27 '19 at 11:18
  • Then perhaps you need to improve your question to include what exactly the requirements are and what specifically you are stuck on, remember asking for tutorials is out of scope on SO – BugFinder Jun 27 '19 at 11:32
  • Agree with BugFinder, it depends on which kind of credentials (username and password), if you want to enter the username and password when starting the process, you could check the [Process.Start overload Method](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.start?view=netframework-4.8#System_Diagnostics_Process_Start_System_String_System_String_System_Security_SecureString_System_String_), if you mean the credentials to access remote web site, perhaps you need to create an Http Request to get the file data, then, download it to local. – Zhi Lv Jun 27 '19 at 12:57

1 Answers1

0

Maybe you are looking for this: How to make HTTP POST web request

There are several ways to enter a password on a site. The way that BugFinder mentioned may be used on sites that require a password to open it. I don't think it would be a GET Request, because a password inside a URL is no good idea. I think when you talk about Textboxes, it would be a normal website with a Form, that sends a POST to the next site, where you may or may not get the download. The "next site" can be the same site.

JP-Hundhausen
  • 70
  • 1
  • 7