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

[Solved] How to use MVC 3 GlobalFilters with Telerik MVC Grid?

3 Answers 108 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Carl
Top achievements
Rank 1
Carl asked on 07 Apr 2011, 01:14 AM
I would like to use the GlobalFilters now available in MVC 3 that are registered with

      RegisterGlobalFilters(GlobalFilters.Filters);

so that I can use a

      filters.Add(new HandleErrorAttribute
      {
        ExceptionType = typeof(DbException),
        View = "GtgError",
        Order = 1
      });

for more convenient handling and analysis of database errors that result in server 500 bombs.

I am able to get it to work in a simple MVC3 app that does NOT use a Telerik Grid, but I cannot get it to work when placed in the MVC3 app with a Telerik Grid.

I noticed that the Telerik demos do NOT use any GlobalFilters. Is it possible to do so? Could Telerik please provide a simple demo of a GlobalFilter used with the Telerik Grid?

Thanks.

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 07 Apr 2011, 10:27 AM
Hello Carl,

I'm afraid that I was unable to observe the behavior you have described. I have attached a basic mvc application which use a dummy global filter implementation. If you run the project in debug mode you will notice that the custom attribute is executed for all requests as expected.

All the best,
Rosen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Carl
Top achievements
Rank 1
answered on 07 Apr 2011, 06:26 PM
Thanks for help. But the sample you provided does NOT test/demo the desired functionality. Your sample tests a DummyFilterAttribute that inherits from an ActionFilterAttribute instead of the feature that I'd like to use which is a HandleErrorAttribute.

For more info and a simple demo of HandleErrorAttribute, see the blog post by tdupont at

http://community.codesmithtools.com/CodeSmith_Community/b/tdupont/archive/2011/03/01/error-handling-and-customerrors-and-mvc3-oh-my.aspx

Now using the approach described by tdupont, I can demonstrate that the HandleErrorAttribute feature is working correctly with RegisterGlobalFilters(GlobalFilters.Filters) in my MVC 3 Razor app on pages that do NOT have a Telerik MVC grid.  Unfortunately, for a page with a Telerik MVC grid, I continue to experience the dreaded server 500 error bomb with a popup window that has the message "Error! The requested URL returned 500 - error" and an OK button.

So it would be extremely helpful if Telerik would provide a real sample that has a MVC grid accessing a real database (like Northwind or something) and that demonstrates successful use of GlobalFilters with a HandleErrorAttribute based filter for SQL database errors that traps and displays those errors in a helpful way instead of just displaying the 500 error message popup window.

Thanks.
0
Accepted
Rosen
Telerik team
answered on 08 Apr 2011, 09:42 AM
Hello Carl,

I'm afraid that HandleErrorAttribute does not work during ajax requests. You may refer to this post on how to workaround this limitation. A similar approach may be applied in case of grid's ajax binding by handling onError client event.

All the best,

Rosen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Carl
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Carl
Top achievements
Rank 1
Share this question
or