日期:2012-01-12  浏览次数:20513 次

 Sreedhar Koganti [@hotmail.com]
Is any one got System.Net.WebException: The request failed
with HTTP status 401: Access Denied.

I created a web service. and i tested with test page.

After i counume it in aspx page[in the same machine] i got
the above error.

Is i am missing some thing, regaarding permissions.

Thansk
Sreedhar





  Madhu [@microsoft.com]
This is permissions problem.

Can you please give me more info about this problem

(1)What is iis security you are implementing like anonymous,basic,..
(2)Are you able to browse web service from IE from remote machine

I have problem with similar eroor,may be going through this problem will
give you better idea on your problem

--------------------------------------------------

PROBLEM:

2 web sites hosted on a Windows 2000 machine. The default website has an
ASPX
WebForms page that calls into an ASMX Web Service. The second website is
mapped to a port other than 80. The webforms page executes without a
problem
if the call to the web services is commented out. The Web Service executes
without a problem if we browse to the ASMX file directly. When the Web
Service IIS application has anonymous access disabled then the following
error
is reported back to the WebForms page that tries to access it?

The request failed with HTTP status 401: Access Denied.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about
the error and where it originated in the code.

Exception Details: System.Net.WebException: The request failed with HTTP
status
401: Access Denied.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be
identified using the exception stack trace below.     

Stack Trace:

[WebException: The request failed with HTTP status 401: Access Denied.]
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClient
Mes
ssage message, WebResponse response, Stream responseStream) +1174
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName,
Object[] parameters) +216 TestClients.ws.Service1.Test1() in
d:\worksets\vswebcache\dotnettest1_8080\testclients\web
references\ws\reference.cs:37 TestClients.WebForm1.btnTest1_Click(Object
sender, EventArgs e) in
d:\worksets\vswebcache\dotnettest1_8080\testclients\webform1.aspx.cs:51
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stB
BackEvent(String eventArgument) +58
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,
String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1263    

<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
<>

RESOLUTION:

Proxy classes created using the Web Services Description Language (WSDL)
tool
(Wsdl.exe), or created when adding a Web reference in Visual Studio.NET,
derive from the SoapHttpClientProtocol class. These classes have a
Credentials
property, which can be used to get or set security credentials for Web
Service
client authentication.

To use the Creden