I am having problems capturing traffic sent and received from my C# application.
The application is an ordinary WinForms application using C# 5.0 and .NET 4.5. .
Fiddler captures traffic from Chrome and Firefox with no issues, just not my application. I have also loaded another application that I developed, and that works fine.
It may be worth noting that this is the first application I've developed that uses HttpClient to make Http requests. Could that be causing any issues?
To be clear the Fiddler Application monitors the traffic. I am not connecting to localhost. I am connect to web API's.
Step #1 is to try starting Fiddler before starting your application. This helps the default configuration, whereby .NET applications pick up the system proxy when they start and are oblivious to proxy changes after they start.
Step #2, if the first step doesn't work, is to explicitly configure your process to use the proxy by editing the app.exe.config file or the machine.config file, or by setting the Proxy property on the request object.
Related
So I got it to the stage where the .net (framework) console application could run on localhost, but the next issue is exposing it using Nginx.
I looked at many tutorials, but they all seems to be for websites. How can i make it work for a console app?
Thank you.
What do you gain from using nginx in front of it instead of just
opening the console app on port 80 (or preferably 443 witha
certificate)? You will probably need to set up nginx as a reverse
proxy for your app.
I have the console app running on port 1234 because there is already an app using port 80. To be honest, I am not sure why I am using Nginx, I just assume that's what I need, since I have the app running on localhost but I cannot access it from outside. I have set the firewall to accept that port from the domain provider side.
uhm.... what exactly do you mean by "exposing a console application"?
because what you expose with nginx - or any other webserver - is a
website. also: welcome to stackoverflow. i recommend taking the tour,
as well as reading how to ask a good question and what's on topic.
Thank you. I am probably not using the most accurate term. Basically, I just want people to be able to access my app. In my mind, I imaging there is some additional setting I need to do to have it "exposed" to the public (and that's using nginx). I can see the app running on localhost but not sure why it's not public.
please say what you expect a console app 'exposed to the public' would
look like. How would they access it? What tool on my desktop would I
start, ignore the nginx part of the discussion
So I have a loop serving some web content similar to this one.
https://gist.github.com/define-private-public/d05bc52dd0bed1c4699d49e2737e80e7
When I run it, external user should go to a website and see the page content served up by this.
If your console app is a Console.ReadLine() Console.WriteLine() type
thing the only way to expose it simply is to setup and SSH server on
your host system. Then the users need an SSH client to access it. This
is doable via web browser hosted SSH access but thats v complex
solution
You can ignore all the Console Readline and Writeline stuff.
Ok, so the solution is actually quite simple. All you need to do is forward your incoming request to a localhost using proxy_pass, as suggested by #fredrik. The following should be added to the default config file (under nginx):
server {
listen 80;
listen [::]:80;
server_name example.com;
location / {
proxy_pass http://localhost:8888/;
}
}
I'am trying to integrate C# Web Browser control and Fiddler Core. I wan't to do this by letting Fiddler Core to listen to the Web Browser control without affecting any internet explorer or other internet browsers.
The diagram below should show what I want to achieve:
Internet Explorer -> Internet
Chrome -> Internet
Other Browsers -> Internet
Web Browser Control (Custom C# App) -> Fiddler Core -> Internet
The four instance below should run parallel without fiddler core interfering with other browsers. So if I wan't to change the response HTML in my Custom App, this will not affect the other browsers.
I've been searching on Google for a while now but I cannot see any concrete example to get me started.
Thank you in advance guys, any help would be greatly appreciated.
FiddlerCore exposes the calling process information in each session's X-ProcessInfo flag.
By default, FiddlerCore will register as the system proxy and most applications will automatically route their traffic through it.
If you want to capture traffic from only a single application, the steps are:
Don't register as the system proxy when calling .Startup.
The target application's proxy settings must be pointed at FiddlerCore's port.
Now #1 is trivial, but #2 is harder, and depends entirely on what networking code the target application uses. You mentioned that the target application is a custom C# application hosting the .NET Web Browser control (which is just IE). If that's the case, and if the application is also hosting FiddlerCore, then you need only call
Fiddler.URLMonInterop.SetProxyInProcess("127.0.0.1:8889", String.Empty);
...inside of your application.
Good morning,
I have following scenario: I have solution with two projects - first project is MVC WebClient and second one is WCF Service. I want open Windows explorer on specific location, probably through WCF. I know that it is not possible from pure client so I was thinking if WCF can does it.
Full scenario is: User clicks on button and then windows explorer will be opened.
I have tried do it on my local computer
Process.Start(path);
and it works, but what if I will host it on IIS?
Will it works?
Will it open client's explorer or server's explorer?
If first two steps will work, will I need host WCF service on IIS too or MVC client with service reference is enough?
And if this scenario won't work, can anyone help with some solution for this problem (if is any)?
Many thanks
The only way I could think of doing this purely with a browser would be to require the client to use IE and then embed an ActiveX control. The page would have to run with the highest security privileges so the ActiveX could run unimpeded. The nice thing about this is it would not require much (if any) server-side support. It would all be handled by Javascript.
Otherwise, to make it browser agnostic, you would have to have a listener app running on the client machine, probably as a service or set to start on machine boot (good candidate for the notification area on the taskbar). The listener app on the client machine could establish a connection to the server using WCF, Sockets (whatever you want really) and then when the user presses the button on the WEB application a message is sent from the web server to the client-side listening application. This of course could trigger anything you want on the client-side.
I see several complications with this as well:
1) How do you get the listener installed on the client machine?
If it's really simple you could just send the exe over with instructions where to copy.
You could build an installer or use ClickOnce to deploy it right from the website: http://msdn.microsoft.com/en-us/library/ms973805.aspx
2) Your web application now needs to communicate with a server-side component that is connected to the client-side listener. If you are already using WCF on the server this might not be too bad. If the client-side listener connects to the same web application the user is using it probably wouldn't be too difficult either (use long-polling or web sockets, etc)
3) How do you secure the client-side listener and connect the client-side "session" to the web "session" such that the user clicking on the button in his web browser sends a message to his instance of the client-side listener and not another user's listener.
These are all doable. I wrote an app that worked sort of like this several years ago. There were definitely challenges but we got it working and it has been stable for several years now. We used WCF.
I have just finished writing my c# console application, and I am contemplating embedding a web server into it (probably this one http://webserver.codeplex.com). I don't do much in the way over advanced web coding though, so I am not sure if I can do what I need to.
Basically, I would like to allow users to view the console output of my application in realtime just by visiting the site being served by my application. If I understand correctly, to do something like this it would require AJAX, which a simple C# Web Server wouldn't be able to handle.
Is this correct or is there an easy way to do this I am missing?
How to re-route console output
You will need to write your own TextWriter and make Console use it via Console.SetOut. This writer should notify connected web clients, as well as the original Console.Out.
How to host a COMET-like server
You can use HttpListener and some basic async programming to do this. If you wrap the HttpListenerContext.Response.OutputStream in a StreamWriter (with AutoFlush set to true) and set HttpListenerContext.Response.SendChunked to true clients will receive partial results - this means you can even do it in an IFRAME.
You will need to add rights to the URL for yourself if UAC is enabled:
netsh http add urlacl url=http://+:9090/ user=domain\username
Code?
I couldn't resist it; I have written a (poorly tested and mostly incomplete) sample.
That is incorrect.
AJAX is a client side technique relying on JavaScript. As long as the web server can respond to an HTTP request, it can server AJAX content (whatever that might mean:-).
I would use this UtilDev Cassini as me embedded web server of choice, it is based on the code from the embedded Visual Studio dev server and can run pretty much anything that runs in IIS. AJAX is a browser technology not a server technology, the server just sees http requests the same as any other. My last point would that it seems slightly odd to embed a web server in a console application. It would be more usual to do this with a windows service. Have you considered converting the console app into a windows service?
I have two solutions, one is the WCF service and the other one is the Silverlight.
I would like to use the debugger on both solutions at the same time. The debugger for the WCF service automatically starts a ASP.NET development server. However, I have a hard time making my Silverlight client connecting to the ASP.NET development server. The error says that I'm lacking of the client domain policy file.
Does anyone know where should I put the clientaccesspolicy.xml for the ASP.NET development server?
Thanks a lot!
clientaccesspolicy.xml needs to be in the root directory for the web server running the WCF service. In your case, this probably means the solution directory for the WCF application (if you're running the web server "in place").
You could also try using Fiddler or Firebug to determine exactly where the file is being requested.