password protected download

NachitoMax 411 Reputation points
2022-09-07T04:51:25.55+00:00

Hey

i am currently downloading some update files for our custom application from an open obscured web location. Ive been asked if i can make it more secure. Im thinking either a web service or some sort of password protected method of downloading. I do see that the My.Computer.Network.DownloadFile has an option to pass a username and password as args but i couldnt find much about how to implement that.

So, whats a good solution? Are there any web services examples out that that i can look at?

Thanks

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,251 questions
{count} votes

2 answers

Sort by: Most helpful
  1. NachitoMax 411 Reputation points
    2022-09-08T14:49:39.017+00:00

    Hi

    I can download, i just need to make it more secure. I get that you can pass a username & password using the method i called out but there doesnt seem to be any documentation that explains how to handle the username & password in order to secure the download. for example: the link you provided shows a text file download with a username=anonymous and a blank password but using the exact same method, you can bypass the username 7 password entirely which doesnt make it secure.

    So im looking for a solution of either

    how to handle the protection of a download using a username & password that cannot by bypassed by skipping the credentials
    how to implement a webservice that i can use to validate a user and permit the download.

    I found a range of webservices but nothing really explains how to implement it on the webserver

    Thanks

    0 comments No comments

  2. XuDong Peng-MSFT 10,096 Reputation points Microsoft Vendor
    2022-09-09T09:19:28.087+00:00

    Hi @NachitoMax ,

    Based on your description, I think what you want to implement is to manually enter account info for authentication every time you download a file, right? Or do you just need to make sure that all files can be downloaded after once authentication?

    1. The first case: You may need to customize a similar modal window to enter account info for users, and then pass these info through the request(e.g. button click event) to the backend for authentication. Finally return the result.
    2. The second case: You just need to make sure the user is logged into the application before downloading the file. When a user tries to download a file, you can get the context of the HttpRequest, and determine the user's login status and return different results accordingly. For example, when the user is not logged in, just redirect to the login page.

    In addition, I'm not sure the custom application you mentioned. If it is a .NET MVC project, you could also implement your requirement via Authorize attribute. Just add it on download file action method. Something like this:

       <Authorize(Roles:="Administrators")> _  
           Function DownladFile()  
               Return View()  
           End Function  
    

    For more details, you could refer to this doc ( for VB.NET): Authenticating Users with Forms Authentication (VB).

    Of course, exactly which method you use to implement it is up to you, or your specific needs and actual situation. But if I have any misunderstanding about this issue, just let me know.

    Best regards,
    Xudong Peng


    If the answer is the right solution, please click "Accept Answer" and kindly upvote. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments