I’d developed small web application using C# and ASP.NET. To simplify developing I used some public web service. So, ASP.NET application invokes methods from external (public) web service. I’d created Web Reference to the web service http://api.morpher.ru/WebService.asmx.
While I’d developed ASP.NET application locally (using IIS Express) everything were ok. It works perfect, without error. Then, I’d deployed its using Visual Studio 2013 “Publish…” menu to the server and had got the error “Unable to connect to the remote server”.
Investigating the C# code I found why I’d got such error. Debugging ASP.NET application at the local PC I have possibility to access Internet without proxy server. But direct access to the Internet from the server is prohibited, so proxy server asked NTLM authorization. To solve the problem I just add several lines of code:
ru.morpher.api.WebService service = new ru.morpher.api.WebService(); IWebProxy proxy = WebRequest.GetSystemWebProxy(); proxy.Credentials = CredentialCache.DefaultCredentials; service.Proxy = proxy;
So, the problem was solved.