Solved

Passing Authentication via HTTP Web Request

Posted on 2010-11-12
9
600 Views
Last Modified: 2012-05-10
I have created an application updater that goes out to a website, downloads a manifest and then via httpwebrequest starts downloading files.  Everything works as it should.  I then decided to add a layer of security and placed a password on the directory.  When you open up a browser and browse to the url you are now prompted for a username and password.  

My question is how can I pass the username and password to my webrequest so the update continues without end user intervention?  This is not on a  network(no AD), I am assuming the website is using basic authentication.  

when i use this method My.Computer.Network.DownloadFile("http://updates.we bsite.com/updates", strManifest, username,password) it works fine.  

Please can you show me how to accomplish this?
0
Comment
Question by:MotherTrker
  • 6
  • 3
9 Comments
 
LVL 1

Accepted Solution

by:
MotherTrker earned 0 total points
ID: 34132715
I have figured this out on my own, for anyone else that is having this problem the below worked for me.  VB.Net 2008

            theRequest = WebRequest.Create(URL)
            theRequest.Credentials = New NetworkCredential("username", "password")
            theResponse = theRequest.GetResponse
in the above order.  This is hitting a site with basic authentication.

Hope this helps someone, i spent a couple days trying to get this to work.
0
 
LVL 19

Assisted Solution

by:Shahan Ayyub
Shahan Ayyub earned 500 total points
ID: 34132716
0
 
LVL 1

Author Comment

by:MotherTrker
ID: 34132723
i figured it out on my own
0
 
LVL 19

Expert Comment

by:Shahan Ayyub
ID: 34132728
No problem. The link has the same content.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Author Comment

by:MotherTrker
ID: 34132731
Shahan,
I bet I was closing this as you were typing.  Thank you for the pointer, I was able to get this working prior to.  Had you been a bit quicker I would of awarded you some points for posting. I am not sure If I still can be if so, i will make it happen.

Thanks.
0
 
LVL 1

Author Comment

by:MotherTrker
ID: 34132737
Sahan deserves points on this, I was able to figure out the solution but Sahan pointed me to a great article that would help out anyone attempting to do the same.  Please award him points
0
 
LVL 1

Author Comment

by:MotherTrker
ID: 34132746
Thanks Sahan
0
 
LVL 19

Expert Comment

by:Shahan Ayyub
ID: 34132757
I just see this question and I had the link I posted to you. So when I posted I see another comment on the same time :)

You have already posted an objection which can leads to give points to me. Thank you for consideration.
0
 
LVL 1

Author Closing Comment

by:MotherTrker
ID: 34171306
Thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now