S
S
Sebastian Pereira2014-12-08 00:23:44
.NET
Sebastian Pereira, 2014-12-08 00:23:44

c# webview. How to run a web client bypassing the proxy?

Hello. Not strong in C# programming, but I need to add functionality to programs.
There is an already written web client with source codes. It takes the proxy settings from the server from the system. I found information that you can register your proxy or disable it completely in the web client.

public static void DisableForMyRequest (Uri resource)
{
    WebRequest request = WebRequest.Create (resource);
    request.Proxy = null;
    WebResponse response = request.GetResponse ();
}

I try to just add these lines, and naturally,
I get errors.
Here is the beginning of Main.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;

namespace blablaclient {

    public partial class MainWindow : LockNotificationForm {
        public MainWindow() {
            InitializeComponent();
            PostInitialize();
        }

Tell me what to enter where and how to start this client outside the proxy.
*Sorry for the confusion. Indeed, I do not know the language, and unfortunately the deadline for the project is "yesterday". Help me please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mayorovp, 2014-12-08
@mayorovp

It is necessary to add not "these lines", but "this line". Specifically, turns off the use of a proxy string request.Proxy = null; - you need to find all the places where requests are created, and add a similar line to each. I say "similar" - because the name of the variable (which is request) may differ.
By the way, requests can be created not only through WebRequest - but also through WebClient.
---
Fortunately, in fact, this task does not even require you to recompile the program again. We need to take the configuration file for the program (for the foo.exe program it will be called foo.exe.config), and do the following in it:

<configuration>
  <system.net>
    <defaultProxy enabled="false" />
  </system.net>
</configuration>

But here we must remember that if there are already some sections in this file, then they must be combined with those given above, and not duplicated. So, the root configuration element in this file will probably already be there - you don’t need to add a new one.
Details on the declarative configuration of the use of a proxy server are here .
---
PS obviously you are not a programmer. How did it happen that you were given such a task?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question