This question is locked. New answers and comments are not allowed.
In the previous version everything worked fine. Now I'm sometimes getting the following error:
[NullReferenceException: Object reference not set to an instance of an object.]
Telerik.Web.Mvc.Infrastructure.Implementation.ControllerAuthorization.IsAccessibleToUser(RequestContext requestContext, String controllerName, String actionName, RouteValueDictionary routeValues) +105
Telerik.Web.Mvc.Infrastructure.Implementation.NavigationItemAuthorization.IsAccessibleToUser(RequestContext requestContext, INavigatable navigationItem) +218
Telerik.Web.Mvc.UI.<>c__DisplayClass2`1.<IsAccessible>b__1(T item) +47
System.Linq.Enumerable.Any(IEnumerable`1 source, Func`2 predicate) +151
Telerik.Web.Mvc.UI.NavigatableExtensions.IsAccessible(IEnumerable`1 items, INavigationItemAuthorization authorization, ViewContext viewContext) +185
Telerik.Web.Mvc.UI.NavigationItemContainerExtensions.WriteItem(TItem item, TComponent component, IHtmlNode parentTag, INavigationComponentHtmlBuilder`1 builder) +643
Telerik.Web.Mvc.UI.<>c__DisplayClass4.<WriteHtml>b__3(MenuItem item) +24
Telerik.Web.Mvc.Extensions.EnumerableExtensions.Each(IEnumerable`1 instance, Action`1 action) +135
Telerik.Web.Mvc.UI.Menu.WriteHtml(HtmlTextWriter writer) +230
Telerik.Web.Mvc.UI.ViewComponentBase.Render() +82
Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.Render() +22
I see that now you changed implementation of IsAccessibleToUser(RequestContext requestContext, string controllerName, string actionName, RouteValueDictionary routeValues) method. I don't know on which line of code it happens (because do not use "ArgumentNullException"). But I presume that I happens on line 75:
var authorizeAttributes = FilterProviders.Providers.GetFilters(authorizationContext.Controller.ControllerContext, authorizationContext.ActionDescriptor).Select(f => f.Instance).OfType<AuthorizeAttribute>().ToList();
You do not validate whether returned "authorizationContext" is null ( you do it later). Please fix it.
Please note that all my URLs specified in sitemap.config file are valid. Or at least throw a descriptive exception which controller/action is missing.
[NullReferenceException: Object reference not set to an instance of an object.]
Telerik.Web.Mvc.Infrastructure.Implementation.ControllerAuthorization.IsAccessibleToUser(RequestContext requestContext, String controllerName, String actionName, RouteValueDictionary routeValues) +105
Telerik.Web.Mvc.Infrastructure.Implementation.NavigationItemAuthorization.IsAccessibleToUser(RequestContext requestContext, INavigatable navigationItem) +218
Telerik.Web.Mvc.UI.<>c__DisplayClass2`1.<IsAccessible>b__1(T item) +47
System.Linq.Enumerable.Any(IEnumerable`1 source, Func`2 predicate) +151
Telerik.Web.Mvc.UI.NavigatableExtensions.IsAccessible(IEnumerable`1 items, INavigationItemAuthorization authorization, ViewContext viewContext) +185
Telerik.Web.Mvc.UI.NavigationItemContainerExtensions.WriteItem(TItem item, TComponent component, IHtmlNode parentTag, INavigationComponentHtmlBuilder`1 builder) +643
Telerik.Web.Mvc.UI.<>c__DisplayClass4.<WriteHtml>b__3(MenuItem item) +24
Telerik.Web.Mvc.Extensions.EnumerableExtensions.Each(IEnumerable`1 instance, Action`1 action) +135
Telerik.Web.Mvc.UI.Menu.WriteHtml(HtmlTextWriter writer) +230
Telerik.Web.Mvc.UI.ViewComponentBase.Render() +82
Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.Render() +22
I see that now you changed implementation of IsAccessibleToUser(RequestContext requestContext, string controllerName, string actionName, RouteValueDictionary routeValues) method. I don't know on which line of code it happens (because do not use "ArgumentNullException"). But I presume that I happens on line 75:
var authorizeAttributes = FilterProviders.Providers.GetFilters(authorizationContext.Controller.ControllerContext, authorizationContext.ActionDescriptor).Select(f => f.Instance).OfType<AuthorizeAttribute>().ToList();
You do not validate whether returned "authorizationContext" is null ( you do it later). Please fix it.
Please note that all my URLs specified in sitemap.config file are valid. Or at least throw a descriptive exception which controller/action is missing.