Freigeben über


How to connect to TFS through authenticated Web Proxy

Today I was in a customer where the internet access is provided by a WebProxy that requires credentials.

For some reason, although VS can navigate, the Team Explorer was not able to connect to our TFS server, because a 407 error (Proxy authentication required)

To fix this issue you need a custom proxy module that provides the credentials, so I created a simple DLL with this class:

 

 using System;
 using System.Net;
  
 namespace Rido.AuthProxy
 {
     public class AuthProxyModule : IWebProxy
     {
  
         ICredentials crendential = new NetworkCredential("proxy.user", "password");
  
         public ICredentials Credentials
         {
             get
             {
                 return crendential;
             }
             set
             {
                 crendential = value;
             }
         }
  
         public Uri GetProxy(Uri destination)
         {
             return new Uri("https://proxy:8080", UriKind.Absolute);
         }
  
         public bool IsBypassed(Uri host)
         {
             return host.IsLoopback;
         }
  
     }
 }

You should copy this DLL to the %PROGRAMFILES\Microsoft Visual Studio 10.0\Common7\IDE folder, and update the devenv.exe.config file to include the module:

 <system.net>
     <defaultProxy>
       <module type="Rido.AuthProxy.AuthProxyModule, Rido.AuthProxy"/>
     </defaultProxy>
   </system.net>

Comments

  • Anonymous
    October 22, 2011
    Hi, I tried this solution but it does not worked for me, can you please explain it more? if the proxy has a port is it alright to write the url as proxyserver.com:8000????

  • Anonymous
    March 02, 2014
    Yes, it work fine, with VS2012 thanks

  • Anonymous
    October 30, 2014
    it dont work fine with VS2013. VS had abnormal end after VS started up.

  • Anonymous
    December 16, 2014
    Awesome fix for VS 2013 Community ... thanks!!!

  • Anonymous
    January 14, 2015
    Can confirm. Worked for VS 2013 Community. Thanks tons!

  • Anonymous
    January 29, 2015
    Thank you. Working with VS 2015 too.

  • Anonymous
    February 15, 2015
    I cannot use C++ so a little help would be nice. After creating a DLL project in visual studio, i copy/pasted the code, but I get: "System is undefined". missing header? anything else? help please.

  • Anonymous
    April 01, 2015
    This method worked on VS 2013 Community, thanks!

  • Anonymous
    May 04, 2015
    @Stephane Ndong-Mef - This is a C# project, so create a new library project using that language.

  • Anonymous
    June 14, 2015
    Example for VS 2010: File - New project - Visual C# - Class Library (.Net Framework 3.5) Name: Rido.AuthProxy using System; using System.Net; namespace Rido.AuthProxy {    public class AuthProxyModule : IWebProxy    {        ICredentials crendential = System.Net.CredentialCache.DefaultCredentials;        public ICredentials Credentials        {            get            {                return crendential;            }            set            {                crendential = value;            }        }        public Uri GetProxy(Uri destination)        {            return new Uri("http://proxy:port/", UriKind.Absolute);        }        public bool IsBypassed(Uri host)        {            return host.IsLoopback;        }    } }

    • Anonymous
      June 13, 2016
      Can you please tell how to make it work for VS2015 community?
      • Anonymous
        July 06, 2016
        There is no differences using VS2015 community, pro or enterprise. What problem do you have?
  • Anonymous
    August 02, 2015
    Thanks! Worked with VS2015 community RC!

  • Anonymous
    November 16, 2015
    It is working (at least I can connect to TFS) but I cannot authenticate to TFS. It always says that the password  is wrong. Any ideas?

  • Anonymous
    December 12, 2015
    Hi, it's not working for me VS 2013

  • Anonymous
    March 31, 2016
    The comment has been removed

  • Anonymous
    April 12, 2016
    Worked with VS 2015 community with update 2!!!

  • Anonymous
    July 28, 2016
    Works great if you remember to do the following:Replace:[proxy.user] with the Proxy user you need[password] with the proxy password you need[proxy:8080] with the actual proxy address and port you needFor VS2015 the path changes to Microsoft Visual Studio 12.0

    • Anonymous
      February 14, 2017
      Hi,Anyone that can hint on how to include a list of domains as exceptions. I tried a few but not able to solve it.I need the proxy solution for Intranet but when accessing my own tfs on the Intranet this example will as-is use wrong credentials since my on-site tfs uses Windows Authentication.
  • Anonymous
    December 02, 2016
    I have same problem, but Studio deny to open = "your 30 day evaluation has expired..". I can't build anything. Without proxy authentication I can't sign in. This is perfect circle.

  • Anonymous
    December 30, 2016
    The comment has been removed

  • Anonymous
    February 20, 2017
    Funciona bien, Visual Studio 2015, Gracias

  • Anonymous
    April 11, 2017
    The comment has been removed

  • Anonymous
    June 15, 2017
    Any advice on how to go about this for Visual Studio for Mac?

  • Anonymous
    April 10, 2018
    Microsoft knows about this for over 8 years now, and it still causes peoples confusion. Whole MS-hit