Click here to Skip to main content
11,717,570 members (83,336 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET VB.NET
I am creating an intranet application which needs the windows loginname. I am trying to retrieve the user id from System.Net.CredentialCache.DefaultNetworkCredentials and using this user Id to retrieve First and Last name of the user using the web service. It's worked fine in my localhost machine. But the problem is when I am trying to access the site from Development server it is showing the error:

The request failed with HTTP status 401: Access Denied

But the same code is working fine in Test environment.I don't have any idea why these both environment behaving differently. I am using windows Integrated authentication and Anonymous access disabled.

This application was in .net 3.5 and i changed to .net framework 4.0 version using VS2010. This web service is working perfectly in 3.5 version so my question is this version change will make any difference to web service?

Please help me to figure out this issue.

Dim consumeWebService As ws-ProfileService
consumeWebService = New ws-ProfileService
consumeWebService.PreAuthenticate = True
consumeWebService.Credentials = System.Net.CredentialCache.DefaultNetworkCredential
Exception:
 The request failed with HTTP status 401: Unauthorized.
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: Unauthorized.
 
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: Unauthorized.]
   System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +2298
   System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +345
   STOP.gov.cdc.activedirectory_ws.ProfileService.GetUserProfile(String UserID) in C:\Projects\STOP\STOP\Web References\gov.cdc.activedirectory-ws\Reference.vb:81
   STOP._Default.Page_Load(Object sender, EventArgs e) in C:\Projects\STOP\STOP\Default.aspx.vb:54
 
[WebException: Praseetha's findings]
   STOP._Default.Page_Load(Object sender, EventArgs e) in C:\Projects\STOP\STOP\Default.aspx.vb:107
   System.Web.UI.Control.LoadRecursive() +116
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2809

Thanks in advance
Posted 7-Jan-13 11:52am
Edited 7-Jan-13 17:52pm
_Amy53.3K
v5
Comments
Zoltán Zörgő at 7-Jan-13 18:07pm
   
And the error message you got is...?
Christian Graus at 7-Jan-13 18:15pm
   
You keep posting the same (useless) code block. We don't care how you create it. What is the error ? Why do you need to move to .NET 4.0 ? Have you googled the error message ?
Sergey Alexandrovich Kryukov at 7-Jan-13 18:29pm
   
"Not working" is not informative; what you have done in unclear. What have you updated and how, exactly?
This is not even a question.
—SA
prasy123 at 7-Jan-13 19:15pm
   
Please let me know the information given above is enough to figure out the issue or any more details required?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

just in case you are hosting your web service over IIS, make sure to change the application pool ASP .NET version to 4.0 or whatever framework you are using.

Just try it. Hope this may help
  Permalink  
Comments
prasy123 at 7-Jan-13 19:18pm
   
Let me try this..Thanks for you response..
k.Prathap at 8-Jan-13 1:29am
   
web services were available in 3.5 version only and in 4.0 have a concept called WCF services . try to convert it to WCF service
prasy123 at 8-Jan-13 16:55pm
   
Hi HashamAhmad
created new application pool and that solved my issue...Thanks..
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

created new application pool and that solved my issue...Thanks..
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 719
1 OriginalGriff 215
2 F-ES Sitecore 210
3 Maciej Los 140
4 Jochen Arndt 120
0 Sergey Alexandrovich Kryukov 1,494
1 OriginalGriff 535
2 Maciej Los 529
3 Richard MacCutchan 440
4 CHill60 415


Advertise | Privacy | Mobile
Web02 | 2.8.150901.1 | Last Updated 8 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100