RE: access denied on a web service
From: Bruce Johnson [.NET MVP] (MVP)
Date: 12/21/04
- Next message: fernandez.dan_at_gmail.com: "Re: Detect if client has .NET framework installed"
- Previous message: Jack Wright: "ASP.NET web application, IIS and AppDomain (manual restart)"
- In reply to: Edward W.: "access denied on a web service"
- Next in thread: Edward W.: "Re: access denied on a web service"
- Reply: Edward W.: "Re: access denied on a web service"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 20 Dec 2004 21:11:02 -0800
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
>
>
>
- Next message: fernandez.dan_at_gmail.com: "Re: Detect if client has .NET framework installed"
- Previous message: Jack Wright: "ASP.NET web application, IIS and AppDomain (manual restart)"
- In reply to: Edward W.: "access denied on a web service"
- Next in thread: Edward W.: "Re: access denied on a web service"
- Reply: Edward W.: "Re: access denied on a web service"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|