Server Error in '/' Application.

Index and length must refer to a location within the string.
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: Index and length must refer to a location within the string.
Parameter name: length

Source Error:


Line 342:            key[i] = Convert.ToByte(claveHex.Substring(p, 2), 16);
Line 343:            IV[i] = Convert.ToByte(vectorHex.Substring(p, 2), 16);
Line 344:            encrypted[i] = Convert.ToByte(cadena.Substring(p, 2), 16);
Line 345:        }
Line 346:        // desencriptar con Rijndael

Source File: c:\home\site\wwwroot\App_Code\funcionesGenerales.cs    Line: 344

Stack Trace:


[ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length]
   System.String.Substring(Int32 startIndex, Int32 length) +13148947
   funcionesGenerales.Desencriptar(String cadena) in c:\home\site\wwwroot\App_Code\funcionesGenerales.cs:344
   MasterPage.controlURLFriendly() in c:\home\site\wwwroot\MasterPage.master.cs:767
   MasterPage.Page_Init(Object sender, EventArgs e) in c:\home\site\wwwroot\MasterPage.master.cs:31
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +52
   System.Web.UI.Control.OnInit(EventArgs e) +97
   System.Web.UI.UserControl.OnInit(EventArgs e) +87
   System.Web.UI.Control.InitRecursive(Control namingContainer) +142
   System.Web.UI.Control.InitRecursive(Control namingContainer) +318
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +416


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