47
votes

I am having issues with Visual Studio 2013 and our corporate proxy (signin does not work, updates do not work, visual studio gallery does not work, nuget and git fail ). All of these are doing http or https requests. (e.g. http://visualstudiogallery.msdn.microsoft.com/ ). In VS2013 I just get spinning progress bars or messages about no network connection.

No problem with the browser, (chrome, IE, firefox) since they all understand proxies (407 rejections and then responding with credentials).

So I want to figure out why VS2013 does not work. But I cannot see any traffic when I tell fiddler2 to watch the DEVENV.EXE process (or all processes).

BTW, I have tried some changes to the web.config (devenv.exe.config) file to make sure it goes to the proxy (I saw this in stack builder) but it is not working for me. See the additions to the section below:

    <system.net>
                <defaultProxy useDefaultCredentials="true" enabled="true">
                 <proxy proxyaddress="http://gw6.OURSITE.com:3128" />
                </defaultProxy>
      <settings>
        <ipv6 enabled="true"/>
        <servicePointManager expect100Continue="false" />
       </settings>
    </system.net>

Update

Eric, I took your suggestion and just stuffed it into the C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe.config file.

What I put in was:

  <system.net>
    <defaultProxy useDefaultCredentials="true" enabled="true">
      <proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false" />
    </defaultProxy>
  </system.net>

What I found was that VS2013 is not sending a user-agent string. It does know about #407 naks and it replies with credentials, but the gateway still wants a user agent:

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: text/html; charset=utf-8
Proxy-Connection: close
Connection: close
Content-Length: 1341

<html>
    <head>
        <title>Access Policy Denied: No User-Agent Specified</title>
        <meta name="description" content="Web Access Policy">
    </head>
    <body>
3
But my issue is not about programs run with Visual Studio as a (DEBUG, etc) with an VS2014. I am running VS2014 as under my account (not a job started by VS). The problem are with VisualStudio itself (it needs to do GIT, NUGET, Sign-IN etc.) all going to microsoft sites. But I can't see which ones are blocked here. - Dr.YSG
Sounds plausible. I looked at C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config and found the <system.web> section and <system.net> is not yet there. But what I did note above is that changing the web.config (devenv.exe.config) for VS2013 itself should have forced VS to go to fiddler. I was surprised it did not. I will test out both and report back (but I am headed out for a vacation so it might have to wait). - Dr.YSG
Can you put your answer down as a seperate post, so that I can star it and give you credit for solving this issue? - Dr.YSG

3 Answers

42
votes

If you want to look at the traffic with Fiddler, you probably want to go the route of changing the machine.config file so that all .NET applications will send traffic through Fiddler. This helps ensure that you capture data from processes running in services, etc.

Open machine.config in the folder C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config. Note that if you are debugging a 64bit service (like ASP.NET) you will want to look in the Framework64 folder instead of the Framework folder. Similarly, if you are using a .NET version prior to 4.0, you will need to adjust the version part of the path.

Add the following XML block as a peer to the existing system.net element, replacing any existing defaultProxy element if present:

<!-- The following section is to force use of Fiddler for all applications, including those running in service accounts -->
 <system.net>
 <defaultProxy
                 enabled = "true"
                 useDefaultCredentials = "true">
 <proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false" />
 </defaultProxy>
 </system.net>

Ref http://fiddler2.com/blog/blog/2013/01/08/capturing-traffic-from-.net-services-with-fiddler

Note: You can use Fiddler to inject a User-Agent header on outbound requests if you like. Also, in the latest version of Fiddler, you can File > Import > Packet Capture to collect HTTP traffic out of .cap files captured using Microsoft NetMon or Microsoft Message Analyzer.

13
votes

My boss suggested another easy way to solve this problem. You can just add "fiddler" in the the uri. For example: http://localhost:52101/ --> http://localhost.fiddler:52101/

9
votes

Alternatively you can use lightweight way like;

if (Debugger.IsAttached) { request.Proxy = new WebProxy("http://localhost:8888/", true); }