Web application cannot talk to web service when run on IIS - c#

I am calling a web service (for sms sending) in my asp.net web application. When my web application is on Developer Server, the web service is called and everything is fine, the expected results are returned. However, when the application is run on IIS, I cannot call the web service and I get this WebException:
"Unable to connect to the remote server"
And in details, InnerException, the message is "No connection could be made because the target machine actively refused it SomeIP:SomePort" where SomeIP is the web service IP address and SomePort is 80
(I was suspecting the problem is the port 80, since pinging SomeIP returns a response but Telnet on SomeIP SomePort fails. But I'm not sure if this is really the problem, I mean, how could the application set a different port when run on IIS!)
I really appreciate any help or ideas!

I had a similar issue wherein the unit test was successfully able to call the external web service, while the asp.net mvc application I was working on was unable to.
I had to a web.config entry to make it work. I am sharing the config entry, which I think, could help people with a similar issue. By the way, this section goes directly under the root element within web.config file. Replace proxy server name and port as applicable in your context.
<system.net>
<defaultProxy>
<proxy proxyaddress="http://<proxy server name>:<port>" />
</defaultProxy>
<!--<defaultProxy enabled="true" useDefaultCredentials="true">
<proxy usesystemdefault="True" bypassonlocal="True" />
</defaultProxy>-->
</system.net>

Related

the remote host name not resolved with MVC solution

I am using api.cognitive.microsoft.com to extract text from images
I have the sample code from microsoft web site.
I did make a console project and configure the webApi and every thing is OK and I have the response
But when I make (or call) this code with MVC it don't work (I did make it directly and I did make it in console project and refer it on the MVC project)
The URL :
string uriBase = "https://westcentralus.api.cognitive.microsoft.com/vision/v2.0/ocr";
I don't know if it linked to the proxy because when I run it on the console application it's OK.
Any suggestions?
The sample code from this link :
Sample code
The error
The remote name could not be resolved: 'westcentralus.api.cognitive.microsoft.com'
I found the solution for my case.
It was about the proxy.
I did add this section to my webConfig:
<system.net>
<defaultProxy enabled="true">
</defaultProxy>
</system.net>

Is there any way to bypass a proxy when using QueueClient in the new .Net standard Azure API - Microsoft.Azure.Servicebus?

I'm currently working on a .net core application that uses a azure service bus queue.
We are restricted to using AMQP over websockets and are behind a corporate proxy.
The QuietClient class does not provide anyway to set proxy information in any of it's constructors and we get a
"Cannot connect to remote server" error when we attempt to write a message to the queue.
The exact same code works when I use it from home - not behind a proxy!
In regular .net bypassing a proxy could be achieved by adding to default proxy configuration in the web.config.
<defaultProxy enabled="true" useDefaultCredentials="false">
<proxy usesystemdefault="True" proxyaddress="http://someAddredd:8888" />
......
</defaultProxy>
Because this is a .net core application the app doesn't use a web.config file for it's configuration.
When deployed to IiS a light weight web.Config file is created to allow the IIS to integrate with core's kestrel web server. However, adding the bypass proxy info to this does not work.
Any help would be much appreciated!

Metadata contains a reference that cannot be resolved: while creating record in MS CRM 2016 Online Using WCF service as Client

I using an wcf service to create record in MS CRM 2016. When i consume service by hosting it on localhost i get responce but when i tried to consume after hosting it on IIS it gives above error. Problem is when i execute any CRM operation in service then only it gives above error otherwise it works fine.
//var httpWebRequest = (HttpWebRequest)WebRequest.Create(string.Format("http://localhost:42078/Service.svc/CreateXML"));
var httpWebRequest = (HttpWebRequest)WebRequest.Create(string.Format("http://10.103.40.109/Service.svc/CreateXML"));
Here first commented line works fine but when i try second line it gives error.
It is the firewall of my server which were causing issue what i just do is add defalut proxy in my wcf service config file under configuration tag. And it solved my issue.
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true">
<proxy bypassonlocal="True" proxyaddress="http://proxyaddress:port"/>
</defaultProxy>
</system.net>

The remote name could not be resolved: 'xxx.table.core.windows.net'

I have created a cloud service to get error logs and hosted it on Azure. It is working perfectly there, but when i host the same application on IIS, it is giving
error.
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 remote name could not be resolved: 'xxx.table.core.windows.net'
I am not supposed to show a code piece. Also i know that a duplicate post exists at The remote name could not be resolved, but the answers there couldn't remove my error. Any help is appreciated
Try to host on a colleague's computer. If it works there, re-install IIS
If the code works on localhost and on Azure, but doesn't work on IIS, it mostly smells of a proxy issue. (since connectivity/DNS resolution will affect all scenarios on the same box) Proxy is something that behaves differently between IIS Express and IIS etc.
So find out if you use a proxy and if you do, add that info to the web.config.
<system.net>
<defaultProxy>
<proxy usessystemdefault="False" proxyaddress="https://myproxy"
autoDetect="False" bypassonlocal="True" />
</defaultProxy>
</system.net>
The proxy might be interfering with the request.

What is a good proxy for me to install and test my Windows Service?

The deployment requirements for my app (a windows service written in C#) state the presence of a Proxy server.
From my interaction with the person who will install my app:
1. His company blocks access to internet via the proxy
2. He needs to provide the path to the proxy script in his IE Config.
3. He also needs to input a user-name/password.
My application needs to access a publicly hosted WebService. In preparation, I sent him a test Winform app. In the app.config file I used the setting mentioned in this post .NET client app: how to reach Web Services in case of proxy?
However, it did not work. I customized the proxy setting in App.config as per his IE settings, yet nothing seemed to work.
I don't want to hard-code the proxy settings in my app using the System.Net classes. There is no doubt in my mind that I want to use the config file.
So, I want to install a proxy on a VPC image and try and get my application to run.
My question:
1. What is a good proxy that I can install on my VM (windows only - no linux/squid pls.) that will replicate the behaviour that I mentioned in 2 & 3 above.
2. In case it is of interest, the proxy settings I used was:
<system.net>
<defaultProxy >
<proxy usesystemdefault= “False“ proxyaddress=“http://10.1.10.10:8080“ bypassonlocal=“True“ />
</defaultProxy>
</system.net>
Assuming that the system will read the settings from IE, I also tried
<proxy autoDetect="true" />
It did not work.
Pls. let me know if my requirements are unclear.
The open source squid proxy has Windows binaries.
If you have a Windows Server OS in you VPC, you could try out Microsoft's very own ISA Server. There's a 180-day trial version here.

Categories

Resources