Index and count must refer to a location within the string. Parameter name: count
13,201
You can't remove 13 characters from the string, containing less that 13; that is what error stated. What is the content of Usuario after the first assignemt?
Usuario = Request.ServerVariables["LOGON_USER"];
Usuario = Usuario.Remove(0, 13);
Author by
Mauricio F
Updated on June 04, 2022Comments
-
Mauricio F almost 2 years
i'm getting mad with this error! The complete error is:
[ArgumentOutOfRangeException: Index and count must refer to a location within the string. Parameter name: count] System.String.RemoveInternal(Int32 startIndex, Int32 count) +0 System.String.Remove(Int32 startIndex, Int32 count) +22 Digi_Proveedores.SiteMaster.Page_Load(Object sender, EventArgs e) in C:\Users\User\documents\visual studio 2010\Projects\INV\Digi_Proveedores\Digi_Proveedores\Site.Master.cs:16 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +91 System.Web.UI.Control.LoadRecursive() +74 System.Web.UI.Control.LoadRecursive() +146 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
The code of the Digi_Proveedores.SiteMaster.Page_Load is:
protected void Page_Load(object sender, EventArgs e) { string Usuario; Usuario = Request.ServerVariables["LOGON_USER"]; Usuario = Usuario.Remove(0, 13); DBConnection Mov = new DBConnection(); lbl_User.Text = Mov.ConsultaUsuario(Usuario); }
When i excecute the code in my local pc it's works fine, the problem is at the ISS7.
I can't understand how can i solve the error. If anyone can help i'd be really grateful.
Thanks!.