"Length cannot be less than zero." on a blank line
<p>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.</p>

<p>This works perfectly in debug mode, it's only in the deployment that this came up.</p>

<p>Original code:</p>

<pre><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:\&lt;file path&gt;\Default.aspx.cs    Line: 23 
</code></pre>

<p>Test code (same error):</p>

<pre><code>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:\&lt;file path&gt;\Default.aspx.cs    Line: 23 
</code></pre>

<p>Here's the stack trace if it helps at all:</p>

<pre><code>[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:\&lt;file path&gt;\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
</code></pre>
