Index and count must refer to a location within the string. Parameter name: count

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:UsersUserdocumentsvisual studio 2010ProjectsINVDigi_ProveedoresDigi_ProveedoresSite.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!.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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);


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x