I have been using Visual Studio 2010 for the last few years but today we were required to update to 2013. I went to open my existing project, which worked without any issues previously but now throws the following error:
A first chance exception of type 'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll
Additional information: startIndex cannot be larger than length of string.
This error is triggered at this line of code:
string logon_user = Request.ServerVariables["LOGON_USER"].Substring(7);
Any ideas on how to resolve this? After some research I found a simple workaround by using this line instead:
string logon_user = System.Security.Principal.WindowsIdentity.GetCurrent().Name.Substring(7);
But I am more interested in finding out the reason why Request.ServerVariables doesn't work anymore. I am using this in tons of other projects and would like to see if it's something I can resolve without changing the line in every project.