错误:远程服务器返回错误:(401)未经授权

时间:2012-07-23 03:21:15

标签: c#

当我尝试访问调用WCF函数的表单时,我一直收到此错误。 实际上它适用于我的本地机器但是当它在服务器中时,会发生这样的事情:(

来源错误:

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.  

堆栈追踪:

[WebException: The remote server returned an error: (401) Unauthorized.]
 System.Net.HttpWebRequest.GetResponse() +6115603
 System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +48

 [MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'.]
 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +9439503
 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +345
 Project.WCFUser.Users.HaveAccess(String userid, String filename) +0
 Project.WCFUser.Users.HaveAccess(String userid, String filename) in C:\Documents and Settings\MyPC\My Documents\Visual Studio 2010\Project\Project\Project\Service References\Users\Reference.cs:71
 Project.View.User.Details.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\MyPC\My Documents\Visual Studio 2010\Project\Project\Project\View\User\Details.aspx.cs:50
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

1 个答案:

答案 0 :(得分:2)

通过更改web.config

中的安全设置解决了此错误
<security mode="TransportCredentialOnly">
      <transport clientCredentialType="Windows" proxyCredentialType="None"
       realm="" />
      <message clientCredentialType="UserName" algorithmSuite="Default" />
</security>