Solved

Passing Authentication via HTTP Web Request

Posted on 2010-11-12
9
611 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
LVL 19

Expert Comment

by:Shahan Ayyub
ID: 34132728
No problem. The link has the same content.
0
 
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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Regarding swagger API 1 59
Adjust the codes 3 63
Office 365: Assigning MailboxPlan to a mailbox 8 69
Creating a Windows C++ program in visual studio 2015 5 29
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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

732 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