It looks like you are using the old unmaintained browser capabilities object, and it getting an error on parsing the request data.
Cookie issues while opening any webpage from project
Ugo Alonso Bolarte Carbajal
0
Reputation points
Hello, I'm currently having issues with the below two exceptions when refreshing any webpage in the project after a random number of times. My current theory is that after passing the context for APIHelper, it becomes null for whatever reason or at least the cookie array becomes empty or null. I can't really tell much with the Error Trace as it only mentions a cookie issue and not where the attempted accessing is being made. Any help would be greatly appreciated.
Using:
.NETFramework v4.8
ASP.NET MVC 5.3
public GestionController()
{
model = new GestionModel();
api = new APIHelper(System.Web.HttpContext.Current);
api.VerifyCredentials();
Debug.WriteLine("GestionController created");
}
///APIHelper.cs
public bool VerifyCredentials()
{
HttpCookie currentUnitBuiness= context.Request.Cookies["CurrentUnit"];
string gestionName = context.Request.RequestContext.RouteData.Values["subdomain"].ToString();
if( gestionName != currentUnitBuiness.Value)
{
//...SQL management...
}
}
Exceptions:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
?, in object ArrayList.get_Item(int index)
?, in string[] NameObjectCollectionBase.BaseGetAllKeys()
?, in string CookieBrowserOverrideStore.GetOverriddenUserAgent(HttpContextBase httpContext)
?, in string BrowserHelpers.GetOverriddenUserAgent(HttpContextBase httpContext)
?, in HttpBrowserCapabilitiesBase BrowserHelpers.GetOverriddenBrowser(HttpContextBase httpContext, Func<string, HttpBrowserCapabilitiesBase> createBrowser)
?, in DisplayModeProvider()+(HttpContextBase context) => { }
?, in bool DefaultDisplayMode.CanHandleContext(HttpContextBase httpContext)
?, in IEnumerable<IDisplayMode> DisplayModeProvider.GetAvailableDisplayModesForContext(HttpContextBase httpContext, IDisplayMode currentDisplayMode, bool requireConsistentDisplayMode)+MoveNext()
?, in string VirtualPathProviderViewEngine.GetPath(ControllerContext controllerContext, string[] locations, string[] areaLocations, string locationsPropertyName, string name, string controllerName, string cacheKeyPrefix, bool useCache, out string[] searchedLocations)
?, in ViewEngineResult VirtualPathProviderViewEngine.FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
?, in ViewEngineResult ViewEngineCollection.FindView(ControllerContext controllerContext, string viewName, string masterName)+(IViewEngine e) => { } [0]
?, in ViewEngineResult ViewEngineCollection.Find(Func<IViewEngine, ViewEngineResult> lookup, bool trackSearchedPaths)
?, in ViewEngineResult ViewEngineCollection.FindView(ControllerContext controllerContext, string viewName, string masterName)
?, in ViewEngineResult ViewResult.FindView(ControllerContext context)
?, in void ViewResultBase.ExecuteResult(ControllerContext context)
?, in void ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
?, in ResultExecutedContext ControllerActionInvoker.InvokeActionResultFilterRecursive(IList<IResultFilter> filters, int filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) x 3
?, in ResultExecutedContext ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList<IResultFilter> filters, ActionResult actionResult)
?, in IAsyncResult AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, string actionName, AsyncCallback callback, object state)+() => { }
?, in IAsyncResult AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, string actionName, AsyncCallback callback, object state)+(IAsyncResult asyncResult) => { } [1]
?, in TResult WrappedAsyncResult<TResult>.CallEndDelegate(IAsyncResult asyncResult)
?, in TResult WrappedAsyncResultBase<TResult>.End()
?, in bool AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
?, in IAsyncResult Controller.BeginExecuteCore(AsyncCallback callback, object state)+(IAsyncResult asyncResult, ExecuteCoreState innerState) => { }
?, in AsyncVoid WrappedAsyncVoid<TState>.CallEndDelegate(IAsyncResult asyncResult)
?, in TResult WrappedAsyncResultBase<TResult>.End()
?, in void Controller.EndExecuteCore(IAsyncResult asyncResult)
?, in IAsyncResult Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, object state)+(IAsyncResult asyncResult, Controller controller) => { }
?, in AsyncVoid WrappedAsyncVoid<TState>.CallEndDelegate(IAsyncResult asyncResult)
?, in TResult WrappedAsyncResultBase<TResult>.End()
?, in void Controller.EndExecute(IAsyncResult asyncResult)
?, in void Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult)
?, in IAsyncResult MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, object state)+(IAsyncResult asyncResult, ProcessRequestState innerState) => { }
?, in AsyncVoid WrappedAsyncVoid<TState>.CallEndDelegate(IAsyncResult asyncResult)
?, in TResult WrappedAsyncResultBase<TResult>.End()
?, in void MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
?, in void MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
?, in void CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
?, in void HttpApplication.ExecuteStepImpl(IExecutionStep step)
?, in Exception HttpApplication.ExecuteStep(IExecutionStep step, ref bool completedSynchronously)
System.NullReferenceException: Object reference not set to an instance of an object.
?, in string[] NameObjectCollectionBase.BaseGetAllKeys()
?, in string CookieBrowserOverrideStore.GetOverriddenUserAgent(HttpContextBase httpContext)
?, in string BrowserHelpers.GetOverriddenUserAgent(HttpContextBase httpContext)
?, in HttpBrowserCapabilitiesBase BrowserHelpers.GetOverriddenBrowser(HttpContextBase httpContext, Func<string, HttpBrowserCapabilitiesBase> createBrowser)
?, in DisplayModeProvider()+(HttpContextBase context) => { }
?, in bool DefaultDisplayMode.CanHandleContext(HttpContextBase httpContext)
?, in IEnumerable<IDisplayMode> DisplayModeProvider.GetAvailableDisplayModesForContext(HttpContextBase httpContext, IDisplayMode currentDisplayMode, bool requireConsistentDisplayMode)+MoveNext()
?, in string VirtualPathProviderViewEngine.GetPath(ControllerContext controllerContext, string[] locations, string[] areaLocations, string locationsPropertyName, string name, string controllerName, string cacheKeyPrefix, bool useCache, out string[] searchedLocations)
?, in ViewEngineResult VirtualPathProviderViewEngine.FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
?, in ViewEngineResult ViewEngineCollection.FindView(ControllerContext controllerContext, string viewName, string masterName)+(IViewEngine e) => { } [0]
?, in ViewEngineResult ViewEngineCollection.Find(Func<IViewEngine, ViewEngineResult> lookup, bool trackSearchedPaths)
?, in ViewEngineResult ViewEngineCollection.FindView(ControllerContext controllerContext, string viewName, string masterName)
?, in ViewEngineResult ViewResult.FindView(ControllerContext context)
?, in void ViewResultBase.ExecuteResult(ControllerContext context)
?, in void ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
?, in ResultExecutedContext ControllerActionInvoker.InvokeActionResultFilterRecursive(IList<IResultFilter> filters, int filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) x 3
?, in ResultExecutedContext ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList<IResultFilter> filters, ActionResult actionResult)
?, in IAsyncResult AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, string actionName, AsyncCallback callback, object state)+() => { }
?, in IAsyncResult AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, string actionName, AsyncCallback callback, object state)+(IAsyncResult asyncResult) => { } [1]
?, in TResult WrappedAsyncResult<TResult>.CallEndDelegate(IAsyncResult asyncResult)
?, in TResult WrappedAsyncResultBase<TResult>.End()
?, in bool AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
?, in IAsyncResult Controller.BeginExecuteCore(AsyncCallback callback, object state)+(IAsyncResult asyncResult, ExecuteCoreState innerState) => { }
?, in AsyncVoid WrappedAsyncVoid<TState>.CallEndDelegate(IAsyncResult asyncResult)
?, in TResult WrappedAsyncResultBase<TResult>.End()
?, in void Controller.EndExecuteCore(IAsyncResult asyncResult)
?, in IAsyncResult Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, object state)+(IAsyncResult asyncResult, Controller controller) => { }
?, in AsyncVoid WrappedAsyncVoid<TState>.CallEndDelegate(IAsyncResult asyncResult)
?, in TResult WrappedAsyncResultBase<TResult>.End()
?, in void Controller.EndExecute(IAsyncResult asyncResult)
?, in void Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult)
?, in IAsyncResult MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, object state)+(IAsyncResult asyncResult, ProcessRequestState innerState) => { }
?, in AsyncVoid WrappedAsyncVoid<TState>.CallEndDelegate(IAsyncResult asyncResult)
?, in TResult WrappedAsyncResultBase<TResult>.End()
?, in void MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
?, in void MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
?, in void CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
?, in void HttpApplication.ExecuteStepImpl(IExecutionStep step)
?, in Exception HttpApplication.ExecuteStep(IExecutionStep step, ref bool completedSynchronously)