Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 2nd, 2005, 08:07 AM
Authorized User
 
Join Date: Dec 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default WebRequest Authentication

Hi

I am try to request a HTML file from a server.

Here is my code

string url = "https://www.server.com";

// Create a new webrequest to the mentioned URL.
WebRequest myWebRequest=WebRequest.Create(url);

// Set 'Preauthenticate' property to true. Credentials will be sent with the request.
myWebRequest.PreAuthenticate=true;

// Create a New 'NetworkCredential' object.
NetworkCredential networkCredential=new NetworkCredential("username","password");

// Associate the 'NetworkCredential' object with the 'WebRequest' object.
myWebRequest.Credentials=networkCredential;

// Assign the response object of 'WebRequest' to a 'WebResponse' variable.

WebResponse myWebResponse=myWebRequest.GetResponse();


When i execute the above code i get an (401) Unauthorised error.

Can anyone help PLEASE?








Similar Threads
Thread Thread Starter Forum Replies Last Post
Error with Webrequest mike_remember ASP.NET 1.0 and 1.1 Professional 5 October 17th, 2006 08:01 AM
Experts?? Problem w/ Webrequest MAtkins ASP.NET 1.0 and 1.1 Professional 2 April 9th, 2006 10:21 PM
problem with using WebRequest class in C# anilkumarbv General .NET 0 December 28th, 2004 02:23 AM
WebRequest on local machine burdickdave C# 0 November 5th, 2003 07:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.