Setup proxy for iisexpress outbound http requests - iis

I am trying to connect with a couchbase instance hosted in Azure Kubernetis Cluster. My company network uses a corporate proxy to connect to external network(internet). So we have always configures system proxy in our machines. In Visual Studio when I execute the code in IISEXPRESS the connection call to couchbase timesout because the IISExpress is not using the system proxy I guess. This same issue was also happening for npm once but after I setup npm proxy everything works fine. Now I need a solution for iisexpress. Any help is appreciated. Thanks in advance.

As far as I know, you could add proxy setting in your visual studio application's web.config file to use proxy to access the another server. If you set this setting the IIS express will use the proxy setting.
Details, you could refer to this document and example codes:
<configuration>
<system.net>
<defaultProxy>
<proxy
usesystemdefault="true"
proxyaddress="http://192.168.1.10:3128"
bypassonlocal="true"
/>
</defaultProxy>
</system.net>
</configuration>

Related

ASP.NET Core 2.1 Give me HTTP Error 502.5 - Process Failure

After using deploying my .NET Core 2.1 App to my server, I get the following error when I access the page:
HTTP Error 502.5 - Process Failure
Following Microsoft's always helpful link on the same page (cough cough), I checked the Event View Log and it states:
Application 'MACHINE/WEBROOT/APPHOST/BLAH.COM' with physical root
'D:\inetpub\vhosts\BLAH.com\httpdocs\' failed to start process with
commandline 'dotnet .\blah.dll', ErrorCode = '0x80070002 : 0.
The message was not only unhelpful, but completely irrelevant. I tried to enable the web app's logging in web.config:
<aspNetCore requestTimeout="23:00:00" processPath="dotnet" arguments=".\blah.dll" forwardWindowsAuthToken="false" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" startupTimeLimit="3600" />
Oddly, no files were created in the Log directory until I granted permission to my IWPD process. The files it created weren't in the stdout directory as specified, but were in the parent log directory. They also were empty.
I ran the web app from the command line using:
dotnet .\blah.dll
The application appeared to run and I could see some messages on the screen, but I still got the same 502.2 error accessing the site with no additional information in the logs. I followed the troubleshooting steps for ASP.NET Core 2.1 and it mentioned this:
If the errors occur when making a request to the app, make a request
to the host and port where Kestrel listens. Using the default host and
post, make a request to http://localhost:5000/. If the app responds
normally at the Kestrel endpoint address, the problem is more likely
related to the reverse proxy configuration and less likely within the
app.
I ran the web app from the command line and tried to access it using http://localhost:5000. I was finally able to access the site, but I still got the same 502.2 error via IIS.
It's obvious IIS and Kestrel are not communicating with each other. I don't understand why there's two web servers and how to get them to communicate with each other.
Solved the problem. The installer for the server's IIS module doesn't restart or warn the user to restart IIS. Restarting IIS loaded the necessary module. Clearly, this is a bug by any other name.

Can't connect to IIS Express using IP Address

From what I understand, VS2012 comes with the IIS Express version by default. And it allows you to connect to the development site using IP address. Currently I can connect using http://localhost:22222. But this would not connect using this http://xxx.xxx.xxx.xxx:22222 where xxx just a local IP of the development machine . I have verified that the IIS Express is running and being used. The IE error was http 400 bad request.
I know you have asked question since a long time. I have an answer to this question at this link.
Go to your IISExpress>Config folder, locate applicationhost.config. Change <bindings> as below:
<bindings>
<binding protocol="http" bindingInformation="*:1407:YOUR_IP_ADDRESS" />
</bindings>
Before you do this , you will have to register this IP address using netsh command as below:
If you’re running Windows 7, pretty much all incoming connections are locked down, so you need to specifically allow incoming connections to your application. First, start an administrative command prompt. Second, run these commands, replacing 192.168.1.11:1234 with whatever IP and port you are using:
> netsh http add urlacl url=http://192.168.1.11:1234/ user=everyone
This just tells http.sys that it’s ok to talk to this url.
> netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=1234 profile=private remoteip=localsubnet action=allow
This adds a rule in the Windows Firewall, allowing incoming connections to port 58938 for computers on your local subnet.More information at this link.
Note: Be sure to change the bindings of your project only by locationg its name. You can even keep the localhost binding and add a new one , this way you can access same webpage using the given IP address.
The solution that worked for me was this one:
The one thing that fixed this for me was using the following line in the <bindings> section for my site in the applicationhost.config file:
<bindings>
<binding protocol="http" bindingInformation="*:8099:" />
</bindings>
The key was to simply remove localhost. Don't replace it with an asterisk, don't replace it with an IP or a computer name. Just leave it blank after the colon.
After doing this, I don't need to run Visual Studio as administrator, and I can freely change the Project Url in the project properties to the local IP or computer name. I then set up port forwarding and it was accessible to the Internet.
EDIT:
I've discovered one more quirk that is important to getting IIS Express to properly serve external requests.
If you are running Visual Studio/IIS Express as an administrator, you must not add a reservation to HTTP.SYS using the "netsh http add urlacl ..." command. Doing so will cause an HTTP 503 Service Unavailable error. Delete any reservations you've made in the URLACL to fix this.
If you are not running Visual Studio/IIS Express as an administrator, you must add a reservation to the URLACL.
Where is it located? applicationhost.config :)
Here
%userprofile%\Documents\IISExpress\config folder
or
%userprofile%\My Documents\IISExpress\config folder

WIF federation and domain : never enter into custom SecurityTokenHandler

We have implemented a federation server which works fine in most cases. It relies on ws2007HttpBinding and implements an extension of UserNameSecurityTokenHandler (called CustomSecurityTokenHandler). On our LAN, all works fine.
However, we have the following scenarios which fails :
1) Instead of the local LAN, the server is deployed on Amazon EC2. The client is a WPF application which connects to the server. When the client is installed on pc within a workgroup, the connection is fine.
2) When the PC is located in a AD domain however, we cannot connect. This does not seem to be due to network issues : the connection to EC2 is still ok, we indeed connect to the federation provider, but never enter into the CustomSecurityTokenHandler.
So it looks as if the server was correctly configured for our local LAN, but suddenly gets stuck when the server is on some external network and the client calls from our local domain.
There's probably some kind of remove section in the configuration to do, but I don't see where.
I already have :
<microsoft.identityModel>
<service>
<securityTokenHandlers>
<remove type="Microsoft.IdentityModel.Tokens.WindowsUserNameSecurityTokenHandler, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add type="MyOwnFP.Federation.CustomSecurityTokenHandler, MyOwnFP.Federation"/>
Any idea would be most welcome.
Actually due to a time clock difference between server and client. Resolved by synchronizing my domain with a proper NTP.

Problems connecting Visual Studio to Azure. target machine refused connection?

I have been uploading to Azure for at least six months. From this afternoon onwards I now get messages like this:
There was no endpoint listening at https://management.core.windows.net/xxxxxx/services/hostedservices that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
Unable to connect to the remote server
No connection could be made because the target machine actively refused it 127.0.0.1:8888
Can anyone give me advice on what's wrong. I tried to upload a new management certificate. That worked fine but then said "authentication error".
I have the same problem. It doesn't matter if the Fiddler is ON/OFF or the computer has been restarted - the problem is in Fiddler Option.
The msg was: "Unable to connect to the remote server No connection could be made because the target machine actively refused it 127.0.0.1:8888"
Go=> Fiddler/Tools/Fiddler Option/
Connection Tab:
make sure that "Allow remote computers to connect" is NOT checked
make sure that "Monitor all connections" is NOT checked
Here is a sample video:
http://screencast.com/t/S8y9NbpveSjd
Hope this helps.
Can you please check if Fiddler is running or not? Normally when you run Fiddler it acts as a proxy and listens at port 8888.
Hope this helps.
I have the similar issue. When I use Visual Studio 2013 to download an extension. It can not connect the remote site.
Assi.NET's method doesn't work. Which means unchecked "Allow remote computers to connect" and "Monitor all connections" still can't get rid of the problem.
To fix it, I find in the machine config file, I added something to enable default proxy. Make sure you DISABLE it.
The correct code is:
<system.net>
<defaultProxy
enabled = "false"
useDefaultCredentials = "true">
<proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false" />
</defaultProxy>
</system.net>

How to use MS Azure AppFabric via proxy server in corporate network

I'm testing the Service Bus AppFabric within our corporate network by runnng the Echo service sample from the AppFabric SDK samples (WindowsAzurePlatformAppFabricSDKSamples_V1.0-CS). However, the code seems to hang at the host.Open(), and no exceptions being thrown.
I left the program running like hours but it's still hung at that line with no exceptions.
Does anyone have a hint about this?
Thanks.
Have been struggling with this today as well. You can add the following in your config:
<system.net>
<defaultProxy useDefaultCredentials="true">
<proxy proxyaddress="http://xyz:8080" usesystemdefault="True"/>
<module type="ServiceBusHost.CustomProxy, ServiceBusHost"/>
</defaultProxy>
</system.net>
Unfortunately this does not work in all cases.

Resources