473,387 Members | 1,779 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,387 software developers and data experts.

Badly stuck, Please help

Hi Experts,
I have a page in my inetpub\wwwroot called testpage.asp. I have removed
anonymous access to this page and have checked windows integrated security.
Now when I try to access this page from code I get a 401 error. Why is this?
I am able to acces the page from IE without any problem. what can do to get
around this problem.
here's my code :

try
{
WebClient wc = new WebClient();
NameValueCollection nvc = new NameValueCollection();
string uri;
uri = "http://localhost/testpage.asp";
NetworkCredential nc = new NetworkCredential("raj","");
wc.UploadValues(uri,nvc);

}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}

--
With Regards,
Deepak
Nov 18 '05 #1
4 988
in addition to this it does not matter if i do this or not

NetworkCredential nc = new NetworkCredential("raj","");
wc.Credentials = nc;

"Deepak" <le********@hotmail.com> wrote in message
news:ur****************@TK2MSFTNGP10.phx.gbl...
Hi Experts,
I have a page in my inetpub\wwwroot called testpage.asp. I have removed
anonymous access to this page and have checked windows integrated security. Now when I try to access this page from code I get a 401 error. Why is this? I am able to acces the page from IE without any problem. what can do to get around this problem.
here's my code :

try
{
WebClient wc = new WebClient();
NameValueCollection nvc = new NameValueCollection();
string uri;
uri = "http://localhost/testpage.asp";
NetworkCredential nc = new NetworkCredential("raj","");
wc.UploadValues(uri,nvc);

}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}

--
With Regards,
Deepak

Nov 18 '05 #2
Hi Deepak,

Do you have Windows Authentication enabled in IIS for the directory? Without
this IIS won't be able to authenticate through Windows Auth and fail
immediately with a 401 error...

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
----------------------------------
Making waves on the Web
"Deepak" <le********@hotmail.com> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
Hi Experts,
I have a page in my inetpub\wwwroot called testpage.asp. I have removed
anonymous access to this page and have checked windows integrated security. Now when I try to access this page from code I get a 401 error. Why is this? I am able to acces the page from IE without any problem. what can do to get around this problem.
here's my code :

try
{
WebClient wc = new WebClient();
NameValueCollection nvc = new NameValueCollection();
string uri;
uri = "http://localhost/testpage.asp";
NetworkCredential nc = new NetworkCredential("raj","");
wc.UploadValues(uri,nvc);

}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}

--
With Regards,
Deepak

Nov 18 '05 #3
Hi, Deepak,

You should use:

NetworkCredential nc = System.Net.CredentialCache.DefaultCredentials;

Have a look at:
http://support.microsoft.com/?kbid=811318

Hope this helps
Martin
"Deepak" <le********@hotmail.com> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
Hi Experts,
I have a page in my inetpub\wwwroot called testpage.asp. I have removed
anonymous access to this page and have checked windows integrated security. Now when I try to access this page from code I get a 401 error. Why is this? I am able to acces the page from IE without any problem. what can do to get around this problem.
here's my code :

try
{
WebClient wc = new WebClient();
NameValueCollection nvc = new NameValueCollection();
string uri;
uri = "http://localhost/testpage.asp";
NetworkCredential nc = new NetworkCredential("raj","");
wc.UploadValues(uri,nvc);

}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}

--
With Regards,
Deepak

Nov 18 '05 #4
Thanks Rick, Thanks Martin,
I did have the windows authentication enabled for the root directory, still
no luck.

I got my credentials as suggested by Martin:
NetworkCredential nc = (NetworkCredential)
CredentialCache.DefaultCredentials;

It works perfectly.

Once again guys thanks a lot, you have solved a major problem for me. Your
efforts are much appreciated.

With Regards

Deepak
"Martin Dechev" <de*******@hotmail.com> wrote in message
news:el****************@TK2MSFTNGP10.phx.gbl...
Hi, Deepak,

You should use:

NetworkCredential nc = System.Net.CredentialCache.DefaultCredentials;

Have a look at:
http://support.microsoft.com/?kbid=811318

Hope this helps
Martin
"Deepak" <le********@hotmail.com> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
Hi Experts,
I have a page in my inetpub\wwwroot called testpage.asp. I have removed
anonymous access to this page and have checked windows integrated

security.
Now when I try to access this page from code I get a 401 error. Why is

this?
I am able to acces the page from IE without any problem. what can do to

get
around this problem.
here's my code :

try
{
WebClient wc = new WebClient();
NameValueCollection nvc = new NameValueCollection();
string uri;
uri = "http://localhost/testpage.asp";
NetworkCredential nc = new NetworkCredential("raj","");
wc.UploadValues(uri,nvc);

}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}

--
With Regards,
Deepak


Nov 18 '05 #5

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

Similar topics

3
by: Mike | last post by:
Hey guys I am pulling my hair out on this problem!!!!! Any help or ideas or comments on how to make this work I would be grateful! I have been working on this for the past 4 days and nothing I do...
17
by: JT | last post by:
Help me the following C++ question: Write a program to help a local bookshop automate its billing system. The program should do the following: (a)Let the user enter the ISBN, the system will...
8
by: MLH | last post by:
I use a mouse-down procedure to trap right mouse clicks and CTRL-Right mouse clicks. Running the procedure must put honey or some other sticky substance into my keyboard because subsequent...
1
by: jessebasketball | last post by:
i am a very beginner programmer and am stuck on a very simple problem. I am trying to make a game where the user is presented with a scenerio and options. ie you are standing in the parking lot...
3
by: Ivonne Riedel | last post by:
Hi everybody, I have got a serious problem building an HTTPHandler in codebehind style. I made the following steps: Create an ASP .net Website project Add a generic handler. Rewrite this...
0
by: Willing 2 Learn | last post by:
I'm working on this program below but im stuck. after it finds a match b/ween sentence & non_terminal it will output where these are found in both strings. I need it to spit out the rules with a...
3
by: derbys | last post by:
Hey im stuck on a question that i need to do, i have pretty much the basics of the programme but am not sure how to get it implemented so that it'll work. The question is : Declare a two...
4
by: =?Utf-8?B?TWF1cg==?= | last post by:
My cd is stuck in the drive. I can open the drawer O K but the c d will not come out Help me please -- Maur
1
by: =?Utf-8?B?VHJ1cHRpIERhbGlh?= | last post by:
Hi to all, I am new in this newsgroup and new to .NET also. I am creating an application where I have to perform Mail Merge from my program. I have created a form which contain RTB and user can...
2
by: na23sh | last post by:
can somebody help me on how to run a visual basic project with a visdata.On a user pc without installing visual basic 6?i have tried the package depolyment wizard but it didn't work?can you help me...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.