RE: access denied on a web service

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Bruce Johnson [.NET MVP] (MVP)
Date: 12/21/04


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
>
>
>



Relevant Pages

  • Re: Windows Integrated Authentication and Anonymous access
    ... If your site allows anonymous access, and the user accesses this section, ... The browser *continues* to send these credentials for each subsequent ... the browser window is closed ...
    (microsoft.public.inetserver.iis.security)
  • CredentialCache.DefaultCredentials not working!!!!!
    ... credentials of the current user but its not working correctly. ... off anonymous access and gone thru the code in debug mode but I keep getting ... After a lot of messing around I got it to work on the server (if I navigate ... when I set my browser to automatically logon on. ...
    (microsoft.public.dotnet.framework.aspnet)
  • CredentialCache.DefaultCredentials not working!!!!!
    ... credentials of the current user but its not working correctly. ... off anonymous access and gone thru the code in debug mode but I keep getting ... After a lot of messing around I got it to work on the server (if I navigate ... when I set my browser to automatically logon on. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Login box
    ... If http://MySite/xyz allows anonymous access, ... once the browser has been prompted to send credentials (eg by going ... I checked with other user computers, ...
    (microsoft.public.inetserver.iis.security)
  • Re: access denied on a 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. ... > service is running has anonymous access turned off. ... > order to access a page in that directory, credentials are required. ...
    (microsoft.public.dotnet.framework.aspnet)