C# Webservice HttpStatusCode 500但不在浏览器中

C# Webservice HttpStatusCode 500但不在浏览器中,c#,web-services,wcf-binding,C#,Web Services,Wcf Binding,当我启动一个新的HttpBasicBinding到一个尚未启动的web服务时,由于应用程序池未启动,将导致一个内部服务器错误500。但当我从浏览器启动Web服务时,服务正在启动 在发送新请求之前,如何启动web服务 下面是我的代码: BasicHttpBinding binding = new BasicHttpBinding(); binding.Security.Mode = BasicHttpSecurityMode.TransportCredent

当我启动一个新的HttpBasicBinding到一个尚未启动的web服务时,由于应用程序池未启动,将导致一个内部服务器错误500。但当我从浏览器启动Web服务时,服务正在启动

在发送新请求之前,如何启动web服务

下面是我的代码:

    BasicHttpBinding binding = new BasicHttpBinding();
                binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
                binding.Name = "AXDocumentBinding";

                EndpointAddress address = new EndpointAddress(serviceUrl);

AA_DynamicsAXDocuHandlingClient cls = new AA_DynamicsAXDocuHandlingClient(binding, address);
                cls.ClientCredentials.Windows.ClientCredential = new NetworkCredential(username, password, domain);

string retVal = cls.loadDocumentStr(AreaId, documentFileName, documentIdentification1, documentIdentification2, documentIdentification3, documentIdentification4, documentIdentification5, documentTable);

提前感谢

你说的“启动新的HttpBasicBInding”是什么意思?我的意思是,如何创建web服务正在启动的会话,而不是返回500个内部服务器错误。你能发布一些代码吗?我刚刚编辑了我的帖子