我的自定义asp.net有错误 我的代码asp代码:
IServiceConfiguration<IOrganizationService> orgConfigInfo =
ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(new Uri("http://crm.tadbirgaranbm.com/TadbirgaranMellat/XRMServices/2011/Organization.svc"));
var creds = new ClientCredentials();
creds.UserName.UserName = "user";
creds.UserName.Password = "pass";
using (_serviceProxy = new OrganizationServiceProxy(orgConfigInfo, creds))
{
// This statement is required to enable early-bound type support.
_serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
_service = (IOrganizationService)_serviceProxy;
using (context srv = new context(_service))
{
Account acc = new Account();
acc.thr_FirstName = firstname.Text;
acc.thr_LastName = lastname.Text;
acc.thr_NationalCode = nationalcode.Text;
acc.EMailAddress1 = email.Text;
acc.thr_Mobile = cellphone.Text;
acc.Telephone1 = tel.Text;
srv.AddObject(acc);
srv.SaveChanges();
alert.ForeColor = System.Drawing.Color.Green;
alert.Text = "با موفقیت ثبت شد";
}
}
然后当我在我的visual studio中运行此代码时正常工作但是当我在iis中运行时出现此错误
安全支持提供程序接口(SSPI)协商失败。
描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息:System.ComponentModel.Win32Exception:安全支持提供程序接口(SSPI)协商失败。
来源错误:
在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息。
堆栈追踪:
[Win32Exception(0x80004005):安全支持提供程序接口(SSPI)协商失败。]
System.ServiceModel.Security.WindowsSspiNegotiation.GetOutgoingBlob(Byte [] incomingBlob,ChannelBinding channelbinding,ExtendedProtectionPolicy protectionPolicy)+6115112
System.ServiceModel.Security.SspiNegotiationTokenProvider.GetNextOutgoingMessageBody(Message incomingMessage,SspiNegotiationTokenProviderState sspiState)+1325
System.ServiceModel.Security.IssuanceTokenProviderBase 1.GetNextOutgoingMessage(Message incomingMessage, T negotiationState) +91
System.ServiceModel.Security.IssuanceTokenProviderBase
1.DoNegotiation(TimeSpan超时)+586
[SecurityNegotiationException:目标“http://crm.tadbirgaranbm.com/TadbirgaranMellat/XRMServices/2011/Organization.svc”与“http://crm.tadbirgaranbm.com/TadbirgaranMellat/XRMServices/2011/Organization.svc”的SOAP安全协商失败。有关详细信息,请参阅内部异常。] System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)+14489026 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData,Int32 type)+622 Microsoft.Xrm.Sdk.IOrganizationService.Execute(OrganizationRequest request)+0 Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.ExecuteCore(OrganizationRequest request)+892 Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.Execute(OrganizationRequest request)+254 Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.SaveChange(OrganizationRequest request,IList`1 results)+43
[SaveChangesException:处理此请求时出错。] Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.SaveChanges(SaveChangesOptions options)+1791 crm.Reg.submit_Click(Object sender,EventArgs e)+790 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)+155 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)+3804
答案 0 :(得分:0)
此错误是服务器和Web应用程序之间的时间差。