Server Error in '/' Application.

Length cannot be less than zero.
Parameter name: length

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length

Source Error:


Line 14:         var c1 = HTTP_USER_AGENT.IndexOf("(");
Line 15:         var c2 = HTTP_USER_AGENT.IndexOf(")");
Line 16:         var Device = HTTP_USER_AGENT.Substring(c1 + 1, c2 - c1 - 1);
Line 17:         var ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
Line 18:         var ipaddressx = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

Source File: c:\websites\carrefour.lulusms.com\Default.cshtml    Line: 16

Stack Trace:


[ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length]
   System.String.Substring(Int32 startIndex, Int32 length) +14599229
   ASP._Page_default_cshtml.Execute() in c:\websites\carrefour.lulusms.com\Default.cshtml:16
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +255
   System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors) +94
   System.Web.WebPages.WebPage.ExecutePageHierarchy() +183
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +108
   System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) +144


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4700.0