Is there a way to configure Fiddler 4.6 to capture traffic from one instance of IISExpress running on my Dev machine to a second IISExpress instance running on the same Dev machine?
I am using VS 2017 with one web site that is accessing some Web API methods on a second site running on another instance of IISExpress.
All of the browser to server traffic is captured fine, but I need to go from site to site to test some API calls.
The question is not so clear, but if you wants to communicate one IIS with another, you need to add a proxy like in the example:
var httpClientHandler = new HttpClientHandler
{
Proxy = new WebProxy("http://localhost:8888", false),
UseProxy = true
}
For more info take a look at the Fiddler docs
Related
We are trying to migrate our REST Web API from being hosted as a Windows .NET Core 3.1 stacked web app to a containerized web app on Linux on Azure.
So far we have managed to push the image to the Azure Container Registry where it's being automatically picked up and successfully deployed to an App Service. Unfortunately, the app does not properly work yet. When trying to fetch some configuration data from a (anonymous) end-point from our API (GET https://foo.azurewebsites.net/api/configuration), instead of returning the data - as it used to do - I get a 301 (Moved Permanently) status code that points exactly to itself: location: https://foo.azurewebsites.net/api/configuration which leads to redirection loop.
So far I have no idea why I'm getting a 301 and I'm glad for any hints.
Points of interest:
Docker: the base for the image is: mcr.microsoft.com/dotnet/core/aspnet:3.1
Azure: Authentication / Authorization is switched off
Azure: no Front Doors are installed
The app is correctly serving the Swagger UI.
The Docker image works fine locally.
Here's how I solved the problem: it turned out that the cause for the permanent redirect loop was a conjunction of how the proxy works in the Azure deployment (thanks to Jason Pan for pointing me in that direction) and the following code that we had in our Startup:
services.AddControllersWithViews()
.AddMvcOptions(o =>
{
...
o.Filters.Add(new RequireHttpsAttribute { Permanent = true }); // REMOVE THIS LINE
...
});
Once I removed RequireHttpsAttribute filter, the app started working as expected. And since I've configured the TLS/SSL settings to allow HTTPS only, I think it is safe to omit the filter.
UPDATE 2021-01-20
I've just figured out that there's a better way to do this that does not require to remove the RequireHttpsAttribute filter. The core of the problem is that Kestrel does not know that communication is happening over a secure channel as the reverse proxy is forwarding requests over http to Kestrel. So we need to enable the forwarding of headers. For .NET Core 2.x applications this meant to follow the steps explained in Configure ASP.NET Core to work with proxy servers and load balancers. Luckily, for ASP.NET Core 3.x applications there a much more simpler way (that unfortunately is not mentioned in the official docs yet but was part of the preview 6 announcement): simply set the ASPNETCORE_FORWARDEDHEADERS_ENABLED environment variable to true. This can be done the usual way in the Azure portal under Confguration > Application settings:
I have an application that sends a request to a web service. Unfortunately the application is compiled and the link to the web service is embedded in the application as http. (Yes I know how dumb that is, I didn't write it)
Recently, the 3rd party company is no longer allowing http requests, everything must be https.
The application runs as a webapp on Tomcat. The server is a windows server.
Is there a way to intercept the call to this web service and force it to use https?
As you can't change the application's source code (as it is compiled), and you can't change the web service (as it is 3rd party) either, the only way to solve this problem is making a proxy between the application and web service. To do that, you need to (assume the proxy is running in localhost):
As the web service URL is embedded into the compiled application, in order to let application send HTTP request to our proxy, hosts mapping need to change (e.g. /etc/hosts) to override DNS. For example, if the HTTP request in application is GET http://example.com/api/sample, in /etc/hosts, example.com need to be mapped to 127.0.0.1.
Make a proxy web server in localhost and open the same port as the web service. This proxy is a very simple web server (any backend programming tech can do it), it is only responsible for request-forwarding. In this way, when application send HTTP request to example.com, it sends the request to the proxy server.
After receiving HTTP request from application, the proxy server extract the request URL/header/body and send HTTPS request to example.com's real IP address. Please note: in this HTTPS request, a header host whose value is example.com should be added. 3rd party web service may check this header.
After the real response is returned from example.com, proxy will return it to the application.
Of course, you can also use reverse engineering (Java Decompiler) to get the application's "source code", change the web service URL and then compile again to a webapp. However, as the application may need to update/upgrade and it is may not under your control, this reverse engineering method is not recommended.
You could use a proxy script. Write it in any server-side language you want, for example PHP, set the API URL to this script, the script does the https request for you and pass the results back to your app.
You could also use Apache itself as the proxy and use something like: Apache config: how to proxypass http requests to https
We have 3 tiered architecture:
Web Server - public (web application deployed) App Server - private (webApi deployed) Db Server - private (sql server installed) And my co-worker said, we have this architecture like this, because its a standard architecture that follows everywhere.
We have been using Asp.net application, where we can make api call from Web Server to App Server without any problem.
But now we have been converting our application from Server side to Client side, i.e. we'll only have js, html & css pages in web application, but problem is, we cannot call api using ajax directly from js, because of the two reason.
our App server is on different domain. App server is behind firewall, means it can only be accessed if we are connected to VPN, or we make a proxy on Web Server, and go through that channel. i.e. js<->Web Server Proxy<->App Server<->Db Server. We want to bypass Web Server from the channel, like: js<->App Server<->Db Server without connecting to VPN, because we don't require user to connect to VPN to use our web application.
Please give your suggestions. Thanks..
You have to enable CORS or cross origin resource sharing. You can research more on that but just want to give idea.
Our MVC application communicates via WCF with a services web app (also WCF).
Both apps (MVC & Services) use basic http by default, but we want to prevent server affinity. I made a custom binding that resembles the basichttp, but with settings 'keepAliveEnabled = false'.
The application works as before, but I want to verify if the keep alive is set to false between the UI and services.
How can this be done ?
(WireShark, Fiddler ??)
I found a solution.
I checked this post on SO:
How to use Fiddler to monitor WCF service
and replaced the localhost DEV client setting to my full computer name and I can track all the UI outbound calls now.
I have a Windows service that is calling a web service, passing a string, and returning a success or error message.
Everything has worked fine in all my testing and development... until I tried to roll it out internally on a network with a proxy server. The web service addresses are not internal but they need to bypass the proxy server to work correctly. If I disconnect my machine from our network and access the internet directly it works fine and the web service is accessible, but if I am connected to the corporate network it fails.
I can add a service reference fine because that uses the proxy settings for my user and this address is set to bypass the proxy. I have tried to run the service with my user credentials and it still doesn't work.
This is what I am using to call the web service:
Dim results As String
Dim objJob As CheckValidationKey.ImportProjectInfo = New CheckValidationKey.ImportProjectInfo
objJob.Credentials = System.Net.CredentialCache.DefaultCredentials
results = objJob.CheckValidationKey(ValidationKey)
What I can't seem to figure out is how to bypass the proxy. I have tried options in the app.config without any luck.
I didn't get an answer and would still like one, however, this specific issue is no longer a problem. It turns out that the proxy wasn't even the problem, but rather that the specific network segment I was trying to use had soap requests blocked. All those hours!