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

access denied on a web service

I wrote my web service and I have no problem browsing to the asmx file and
seeing the public methods. I can even invoke them with no problem. But in
my asp.net application I get this error message "The request failed with
HTTP status 401: Access Denied. "

BUT when I add this line to my code it works fine.

gsdiApplication gsdiWebService = new gsdiApplication();
gsdiApplication.Credentials =
stem.Net.CredentialCache.DefaultCredentials; ------ when I add this line
it then works!
gsdiApplication.....
<code here>
gsdi.Dispose();

But I don't understand why I needed to add it? I never had to do anything
like that before. What required it this time?

Ed
Nov 19 '05 #1
2 1865
The short answer is because your web site demands it.

But to be a little less terse, the virtual directory in which your web
service is running has anonymous access turned off. This means that, in
order to access a page in that directory, credentials are required. If you
had hit a page with a browser, then behind the scenes the browser would have
received a request for credentials and provided them. However, the proxy
class used to access a web service doesn't do that. Instead, you need to
provide them, something you're doing by setting the Credentials property. If
you would rather not do this, then turn anonymous access on on the virtual
directory.

Hope this helps.

"Edward W." wrote:
I wrote my web service and I have no problem browsing to the asmx file and
seeing the public methods. I can even invoke them with no problem. But in
my asp.net application I get this error message "The request failed with
HTTP status 401: Access Denied. "

BUT when I add this line to my code it works fine.

gsdiApplication gsdiWebService = new gsdiApplication();
gsdiApplication.Credentials =
stem.Net.CredentialCache.DefaultCredentials; ------ when I add this line
it then works!
gsdiApplication.....
<code here>
gsdi.Dispose();

But I don't understand why I needed to add it? I never had to do anything
like that before. What required it this time?

Ed

Nov 19 '05 #2
thank you. I looked at it further today. What I did was go into internet
manager directly (windows xp pro) and create a new virtual directory for the
web service. Then I created the web service in VS.NET 2003 and pointed to
the URL of the virtual directory I had just created. When I go into the
properties of the virtual directory from within inetmgr, I see as the first
tab it's named "Virtual Directory."

Next I created a new solution and added a web service as a project but I let
VS.NET create the IIS directory. Then in inetmgr, I checked the properties
of the web service site and noticed the first tab is called just "Directory"
and also it has a Server Extensions tab.

So what I did differently than I normally had done was to create the IIS
directory first before I created the web service. I did this so I could
control where the files were, namely not in the inetpub\wwwroot folder.

So my question is, how can I create the directory manually first, and what
do I choose if I shouldn't choose "virtual directory"?

thanks
Ed

"Bruce Johnson [.NET MVP]" <Bruce Johnson [.NET
MVP]@discussions.microsoft.com> wrote in message
news:1B**********************************@microsof t.com...
The short answer is because your web site demands it.

But to be a little less terse, the virtual directory in which your web
service is running has anonymous access turned off. This means that, in
order to access a page in that directory, credentials are required. If
you
had hit a page with a browser, then behind the scenes the browser would
have
received a request for credentials and provided them. However, the proxy
class used to access a web service doesn't do that. Instead, you need to
provide them, something you're doing by setting the Credentials property.
If
you would rather not do this, then turn anonymous access on on the virtual
directory.

Hope this helps.

"Edward W." wrote:
I wrote my web service and I have no problem browsing to the asmx file
and
seeing the public methods. I can even invoke them with no problem. But
in
my asp.net application I get this error message "The request failed with
HTTP status 401: Access Denied. "

BUT when I add this line to my code it works fine.

gsdiApplication gsdiWebService = new gsdiApplication();
gsdiApplication.Credentials =
stem.Net.CredentialCache.DefaultCredentials; ------ when I add this
line
it then works!
gsdiApplication.....
<code here>
gsdi.Dispose();

But I don't understand why I needed to add it? I never had to do
anything
like that before. What required it this time?

Ed

Nov 19 '05 #3

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

Similar topics

0
by: George | last post by:
Hello, I'm running an ASPX application "WebApplication1" which consumes a web service (service1.asmx) hosted on a machine with IP (128.1.7.x) . The web service is located in the intranet. The...
0
by: ASP.Confused | last post by:
The old message looked a little stale, so I am re-posting it here. Anybody have any ideas of what I could do?!? The previous responses to this question are below. If you want to look at the...
4
by: Bruce | last post by:
I am developing an ASP.NET web service application. It works fine on my WinXP Prof development machine. But when I send it to a Windows Server 2003 system I get the following error (attached...
3
by: Shailesh Humbad | last post by:
I figured out what was causing the "Access is Denied" error when calling functions from referenced DLLs in my service. I've tried to be very detailed, so bear with me. It turns out that...
3
by: David Thielen | last post by:
Hi; I created a virtual directory in IIS 6.0 and my asp.net app runs fine. But when it tries to write a file I get: Access to the path is denied. - C:\Inetpub\wwwroot\RunReportASP\images ...
7
by: hufaunder | last post by:
I have a website that uses a web service that is located on the same machine. This webservice calls a program which in return modifies a file in c:\documents and Settings\All Users\Application...
4
by: carson | last post by:
I have written two windows services: - service A does some crunching of local data files and uploads them to a central processing computer via http. - service B monitors a manifest file on a...
0
by: royan | last post by:
Help please! I have the same problem which this post ...
0
by: Andy | last post by:
Thanks Peter, I thought I'd give an update on this problem. My application had 2 assemblies that contained classed for the Data access and business logic layer. It was on one of them that I was...
2
by: =?Utf-8?B?bXVyYWRqYW1lcw==?= | last post by:
Yes, sorry I tried to make it clear in the original question that I want to get the user token of the service - ie. the account the service is running under. I know services don't have user tokens...
1
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: 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...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.