Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4325120
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:13:28+00:00 2026-05-21T09:13:28+00:00

I keep getting the above error message, even if I comment out the line

  • 0

I keep getting the above error message, even if I comment out the line that the error is occurring on. Any idea what could be causing this? I’ve tried re-writing the lines with test values, but I still get the same error.

This works perfectly in debug mode, it’s only in the deployment that this came up.

Original code:

Line 21:             string domain, username;
Line 22:             string text = Page.User.Identity.Name;
Line 23: 
Line 24:             domain = text.Substring(0, text.IndexOf("\\"));
Line 25:             username = text.Substring(text.IndexOf("\\") + 1, text.Length - text.IndexOf("\\") - 1);

Source File: F:\<file path>\Default.aspx.cs    Line: 23 

Test code (same error):

Line 21:             string domain, username;
Line 22:             //string text = "TEST"; // Page.User.Identity.Name;
Line 23:             // this line is blank
Line 24:             domain = "TEST"; //text.Substring(0, text.IndexOf("\\"));
Line 25:             username = "TEST"; // text.Substring(text.IndexOf("\\") + 1,

Source File: F:\<file path>\Default.aspx.cs    Line: 23 

Here’s the stack trace if it helps at all:

[ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length]
System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) +12681546
Insufficiencies._Default.Page_Load(Object sender, EventArgs e) in F:\<file path>\Default.aspx.cs:23
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3048
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T09:13:29+00:00Added an answer on May 21, 2026 at 9:13 am

    text.IndexOf("\\") will be returning -1 if it cannot find "\" in the string.

    You are passing -1 through to the Substring() method, which is invalid.

    The Page.User.Identity.Name will return an empty string if the site is not run with windows integrated authentication exclusively enabled in IIS for that site.

    Users will likely be accessing the site under anonymous authentication.

    From http://msdn.microsoft.com/en-us/library/ff647405.aspx:

    To configure Windows authentication

    • Start Internet Information Services (IIS).
    • Right-click your application’s virtual directory, and then click Properties.
    • Click the Directory Security tab.
    • Under Anonymous access and authentication control, click Edit.
    • Make sure the Anonymous access check box is not selected and that Integrated Windows authentication is the only selected check box.
    • In your application’s Web.config file or in the machine-level Web.config file, ensure that the authentication mode is set to Windows as shown here.
    <system.web>
     ...
       <authentication mode="Windows"/>
     ...
     </system.web>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting the above error, going from my first activity that has a
I keep getting the above error when trying to transform XML that's generated in
I keep getting tasks that are above my skill level. How can I address this without coming accross as grossly incompetent?
G'day folks I keep getting the error above whenever I run this and buggered
I keep keep getting the above error when I run the code below. All
I keep getting the following error message when trying to UPDATE one of my
Keep getting this error after inserting a subdatasheet into a query and trying to
I keep getting a PermGen error on my Tomcat 6 server. I know what
I keep getting a 'List does not exist' error whenever I try and use
We are getting the above error when we try and run our tests in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.