• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 617
  • Last Modified:

Passing Authentication via HTTP Web Request

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
MotherTrker
Asked:
MotherTrker
  • 6
  • 3
2 Solutions
 
MotherTrkerAuthor Commented:
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
 
Shahan AyyubSenior Software Engineer - iOSCommented:
0
 
MotherTrkerAuthor Commented:
i figured it out on my own
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
Shahan AyyubSenior Software Engineer - iOSCommented:
No problem. The link has the same content.
0
 
MotherTrkerAuthor Commented:
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
 
MotherTrkerAuthor Commented:
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
 
MotherTrkerAuthor Commented:
Thanks Sahan
0
 
Shahan AyyubSenior Software Engineer - iOSCommented:
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
 
MotherTrkerAuthor Commented:
Thanks
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now