I have got the a service with the following topology.
A (Web application) ---calls---> B (Local Web Api) ---calls---> C (Remote Web Api)
I am trying to capture the traffic from B to C in Fiddler, but nothing is logged.
B is a web site hosted locally on my dev box in IIS. It's running on an app pool with a credential other than mine as it has a different set of permissions. Traffic going out from B is not getting logged, even after I have done the following redirect:
<system.net>
<defaultProxy
enabled = "true"
useDefaultCredentials = "true">
<proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false" />
</defaultProxy>
What can I do to capture traffic leaving B?
The problem is that the .NET Framework is hardcoded to bypass the proxy for localhost addresses. Change the target address to localhost.fiddler and the traffic will be captured.
Related
I need to configure a default proxy to enable Application Insights.
In an ASP.NET Web Api the default proxy can be set in the web.config like below:
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true">
<proxy proxyaddress="someaddress" bypassonlocal="True" />
</defaultProxy>
</system.net>
With this setting AI works fine. Unfortunately I could not find an option to set the proxy in appsettings.json. Is there any possibility to define the default proxy in an ASP.NET Core Web API?
Or do I have to configure the proxy in IIS, when the application is getting hosted with it?
Edit:
I am setting the default proxy now like this:
WebRequest.DefaultWebProxy = new WebProxy(new Uri("someaddress"), true)
{
UseDefaultCredentials = true
};
When getting the proxy with
WebRequest.DefaultWebProxy.GetProxy(new Uri("https://dc.services.visualstudio.com/v2/track"))
it returns the correct proxy.
Strange things happens when Fiddler is running.
As soon as Fiddler is running the application is logging successfully to AI. When closing Fiddler the logging breaks again.
Has anyone an idea?
Do you mean you want to configure HttpClient proxy globally?
If so, I am afraid it is impossible. You may consider creating an encapsulate class with accepting Proxy configuration and return a HttpClient, you could load the configuration from appsettings.json or anywhere
Perhaps your traffic is going through Fiddler Proxy so when Fiddler shuts down so as your connection to other services.
I have a process running as a different user on my machine that I want to capture HTTP (and HTTPS) traffic with. When I start Fiddler, it only captures processes from my user account.
I'm interested in doing this for both applications I build and applications that I do not have the source code for, as well as instructions for native and .NET applications.
From the Fiddler docs:
C# Applications (you have a few options):
1) Edit the machine.config file:
<!-- Force Fiddler for all .NET processes, including those running under service accounts -->
<system.net>
<defaultProxy>
<proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false" />
</defaultProxy>
</system.net>
2) Edit the program's app.config file using the settings above
3) Specify the proxy on a WebRequest object:
objRequest = (HttpWebRequest)WebRequest.Create(url);
objRequest.Proxy= new WebProxy("127.0.0.1", 8888);
Native Applications (Windows Vista or above):
For Windows 7 and earlier, use the netsh that matches the architecture of your application (32 or 64 bit)
netsh winhttp set proxy 127.0.0.1:8888
When done, you can clear the proxy by:
netsh winhttp reset proxy
Just a small summary of the infrastructure. I have a webservice running on a server in India only accessible through the companies internal network. I'm located in Europe.
The webservice is hosted in its own windows service, so no IIS.
When starting the client the first call allways takes approx 22 sec., this is a simple "ping" operation, just asking if the server is there, so no logic on the server that takes any time.
I have tried this solution First call to a .net webservice is slow with a bypass list. But that doesn't seem to work, unless it's me doing something wrong ?
<bypasslist>
<add address="[a-z]+\.company_name\.com"/>
</bypasslist>
Where the server address is staging.company_name.com
I also tried the other solution that has been suggested in the post, but still no luck.
<configuration >
<system.net>
<defaultProxy>
<proxy bypassonlocal="true" usesystemdefault="false" />
</defaultProxy>
</system.net>
</configuration>
Using fiddler I can see that the above apparently works, because this results in fiddler not being able to capture the traffic.
All the following webservice calls on the client are handled within short time less than 1 sec.
What / How can I reduce the first calls delay ?
UPDATE
This wasn't due to problems with WCF this is a routing / DNS problem on our network in the company....
I have a WCF service deployed to IIS on my local machine configured for Win Auth
<basicHttpBinding>
<binding name="NewBinding0">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
I have a test WPF project that call it which works just fine.
I tried to create a Windows Store app and use my logged on (domain) user to call the service but can't get this to work
My user is a domain user and I can see it by calling Windows.System.UserProfile.UserInformation.GetDomainNameAsync()
If I implement the partial ConfigureEndpoint and set the credentials explicitly I can get to the service just fine -
static partial void ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint, System.ServiceModel.Description.ClientCredentials clientCredentials)
{
clientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("<domain>\\<username>", "<password>");
}
but if I simply put
clientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
I get the following error
{"The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'Negotiate,NTLM'."}
I have configured the Enterprise Authentication and Private Networks (Client & Server) capabilities
What do I need to do to call the service in the context of the logged on domain user?
(I've found this unanswered question which probably refers to the same issue, but no answer yet?
Turns out that the issue was a result of me hosting the service (for testing) on my laptop and calling it using 'localhost'.
I've deployed the same service to another server on our domain and updated the endpoint address in the app and it all worked just fine.
Looks like there's a restriction on windows store app calling services on localhost
Not quite sure why this is working fine if I provide the credentials explicitly and does not if I just carry the logged on user though..
How to setup SMTPClient in ASP.net with C# to send email with provided proxy address ? or sending by detecting the system default proxy
I used the the following code in web.config but didnt work
<system.net>
<defaultProxy enabled="true">
<proxy bypassonlocal="False" proxyaddress="http://192.168.101.3:8080/" />
</defaultProxy>
</system.net>
You can't send SMTP email through an HTTP proxy server.
Speak to the person administering your Internet gateway/firewall to ask what host they want you to direct outbound email to.
Based on this article, you simply have to declare your proxy configuration into your Web.config and try to change the port:
If you are still having problems them try changing port number to 587
Edited my answer after your edit.