473,320 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

HttpWebRequest - How to GET a document from Server

Hi,
While trying to access a document on my server through my C# application ,it
says "Remote Server returned and Error : 401 Unauthorised" but when i access
it thro Internet Explorer it works fine.
I've used CredentialCache object and i've also tried "Authrorization" header
with Base64 algo.

string uidpwd = "abhimanyu:sirohi";
byte[] bytes = new byte[uidpwd.Length];
bytes = Encoding.UTF8.GetBytes(uidpwd);

WebResponse requestResponse = null;
CredentialCache MyCredentialCache = new CredentialCache();
MyCredentialCache.Add(new Uri("PATH"), "NTLM", new
NetworkCredential("username", "password"));
HttpWebRequest Request = (HttpWebRequest) HttpWebRequest.Create("PATH");
Request.Credentials = MyCredentialCache;

Request.Method = "GET";
Request.Headers.Add("Translate", "F");
Request.Headers.Add("Authorization", "NTLM " + Convert.ToBase64String(bytes));

requestResponse = Request.GetResponse();

plz help
regards

Jul 21 '05 #1
0 1113

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jerry Rhodes | last post by:
When I run the code below, the web server tells me that I need to enable cookies. Can anyone tell me what might be causing that? I'm trying to POST userid and password to their login web page. ...
0
by: Wolfgang Meier | last post by:
I am using the following code to retrieve a document from my web server: HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://example.com/"); req.Method = "GET"; req.PreAuthenticate...
16
by: thomas peter | last post by:
I am building a precache engine... one that request over 100 pages on an remote server to cache them remotely... can i use the HttpWebRequest and WebResponse classes for this? or must i use the...
7
by: gorkos | last post by:
Hi, I am two days trying to solve a problem with some pages, which i get through HTTPWebRequest. Error is that some pages need Script to be enabled. But how to do this in HTTPWebRequest class?
0
by: Abhimanyu Sirohi | last post by:
Hi, While trying to access a document on my server through my C# application ,it says "Remote Server returned and Error : 401 Unauthorised" but when i access it thro Internet Explorer it works...
3
by: JansenH | last post by:
We have implemented a 'HTTP Post' client in C# that posts Xml documents to a webserver. This is working fine if the post rate is one post for every 20 seconds. But if the post rate is increased to...
2
by: =?Utf-8?B?U2ltb25EZXY=?= | last post by:
Hi I have a utility class, called MailHandler, that I wrote to read and operate on emails on an Exchange server using WebDAV. The WebDAV SQL statements are sent using an HttpWebRequest object....
7
by: Marc Bartsch | last post by:
Hi, I have a background worker in my C# app that makes a synchronous HttpWebRequest.GetResponse() call. The idea is to POST a file to a server on the internet. When I call HttpWebRequest.Abort()...
15
by: Nightcrawler | last post by:
I am currently using the HttpWebRequest and HttpWebResponse to pull webpages down from a few urls. string url = "some url"; HttpWebRequest httpWebRequest =...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.