This is a migrated thread and some comments may be shown as answers.

Another ControllerAuthorization.IsAccessibleToUser error in Q2 2012

11 Answers 242 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
montgomery
Top achievements
Rank 1
montgomery asked on 12 Jun 2012, 08:10 PM
I get the following error after upgrading to 2012.2.607.340:

[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

The menu worked prior to the upgrade. It fails on approximately 10% of our controllers. Some actions with a route value of {area = ""} work and some fail. Some controller actions within a single controller work and others fail. I cannot find anything to differentiate the ones that succeed and the ones that do not. The level of menu nesting does not appear to be a factor.

This looks to be similar to the issue reported here: LINK

11 Answers, 1 is accepted

Sort by
0
montgomery
Top achievements
Rank 1
answered on 12 Jun 2012, 08:39 PM
I found the problem. We have many areas in our application. As an example, suppose our menu is within Area1. We only use a route value in a menu item Action ({area="Area2"}, for example) when we needed to break out of Area1. However, some of our areas have controllers with the same name. As an example, suppose there are Area1.Expense and Area2.Expense controller classes. I was getting the exception posted above because the AuthorizationContextFactory constructor, when the area name is empty, will find whatever controller matches the name. If I have my menu in Area1 but it finds the Area2 controller class, then my menu will fail with the unhelpful NullReferenceException because of the following lines:
ActionDescriptor actionDescriptor = controllerDescriptor.FindAction(controllerContext, actionName);
            if (actionDescriptor == null)
            {
                return null;
            }

This is confusing because, by default, if you leave the area off, I always assumed it searched with the current area for matching controllers. That does not appear to be the case. That means, if you have a name conflict between controller classes in different areas, you should specify the area name as part of your route values.

My two suggestions are:
1. Return a reasonable error message when no action is found. String.Format("Area:{0} Controller:{1} Action:{2}", areaName, controllerName, actionName); would have just saved me three hours of work.
2. Default the areaName to be the current area if a specific areaName is not specified. This is the intuitive approach for someone working from the aspx side of things only.
0
Georgi Krustev
Telerik team
answered on 13 Jun 2012, 08:21 AM
Hello David,

 
This is a known issue, which is already addressed. You can download the latest internal build, which includes the fix. Please excuse us for the temporary inconvenience this may cause you.

The exception will be  thrown, when the authorizationContext object used in the ControllerAuthorization.IsAccessibleUser is null. For now we decided to avoid throwing exception when the authorization context is null. if other users request such functionality (as the suggested one) we will schedule it for implementation.

As to the second suggestions, the menu is a navigational component and it should be able to navigate between different areas. Hence, I believe that it should not default to the current AreaName. If the area is not defined that the menu should navigate to default controller defined with controllerName argument. This is current behavior.

Kind regards,
Georgi Krustev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Phil
Top achievements
Rank 1
answered on 19 Jun 2012, 07:50 PM
Would love to get my hands on this internal build/fix.  Where can it be downloaded?  Having trouble finding it on your website.
0
Atanas Korchev
Telerik team
answered on 20 Jun 2012, 05:59 AM
Hi Phil,

 The internal builds are available to commercial license holders. If your company is a paying customer please ask the person who made the purchase to add you as a licensed developer.

Regards,
Atanas Korchev
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Emily
Top achievements
Rank 1
answered on 22 Jun 2012, 05:25 PM
Hello Atanas,

When will this fix be available to the Open Source community?

Best Regards,
Emily

0
Atanas Korchev
Telerik team
answered on 25 Jun 2012, 07:36 AM
Hello Emily,

 The next official release is not yet scheduled. I am sending you the file which contains the fix. Replace the existing one in Telerik.Web.Mvc\Infrastructure\Implementation.

Regards,
Atanas Korchev
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Andrei
Top achievements
Rank 1
answered on 26 Jun 2012, 07:52 PM
@Atanas Korchev
> The next official release is not yet scheduled.

I presume that that the next version will be released in 3 months (as it's usually done). Why should the community (open-source) wait 3 months (!!!) just to get a fix for the critical issue. I'm sure that Telerik team should release the new version (open-source) which addresses this issue in the near time. Otherwise, 50% of developers won't be able to use it and can move to some other frameworks.
0
Andrei
Top achievements
Rank 1
answered on 26 Jun 2012, 08:02 PM
BTW, we can specify "controller" and "name" in a sitemap file for menu control. Could we also specify "area" route parameter along with these "controller" and "name" params in the same file? If yes, how?
0
Atanas Korchev
Telerik team
answered on 27 Jun 2012, 06:56 AM
Hi Andrei,

 The update policy of the open source license of Telerik Extensions for ASP.NET MVC is clearly stated on our web site.

 Despite that  I've already attached the updated C# file so open source users can have the fix. Why can't you use the attached file?

Regards,
Atanas Korchev
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Hesham Desouky
Top achievements
Rank 2
answered on 27 Jul 2012, 10:16 PM
A quick fix for this menu issue:

Use the the Url method instead of the Action method

e.g. Url(Url.Action("actionName","controllerName",new {area="YourArea"}))

It works for me
0
Boris
Top achievements
Rank 1
answered on 06 Sep 2012, 08:00 PM
Hi,

Since Kendo replaced the ASP.NET MVC Extension, I can't find the latest internal build that contains the fix for this error. I built a whole project with the old MVC extension and I won't upgrade it to Kendo. Can you tell me how I could get the fix for this? Thanks in advance.

Boris
Tags
Menu
Asked by
montgomery
Top achievements
Rank 1
Answers by
montgomery
Top achievements
Rank 1
Georgi Krustev
Telerik team
Phil
Top achievements
Rank 1
Atanas Korchev
Telerik team
Emily
Top achievements
Rank 1
Andrei
Top achievements
Rank 1
Hesham Desouky
Top achievements
Rank 2
Boris
Top achievements
Rank 1
Share this question
or