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

[Solved] Area name rewriting when filtering grid

3 Answers 32 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.
raouf
Top achievements
Rank 1
raouf asked on 10 Jun 2011, 12:16 AM
Hi

I have a problem I can't solve on my own.

In fact, I am working on a project with aspnet mvc and the telerik mvc extensions.

I have a grid accessible from a controller inside an area. When I display it, it works fine.
The problem come when I try to filter the grid.
The url becomes something like this :
domain.com/area_name/area_name/controller/action?filtering_params

it's rewritten in a way that makes the routing pipeline map the area name to a controller and the controller to an action ...

is there a way to solve this???

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 10 Jun 2011, 08:44 AM
Hello raouf,

 It works when I tested locally. Find attached my test project.

Greetings,
Atanas Korchev
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
Rick
Top achievements
Rank 1
answered on 24 Jan 2012, 11:17 PM
Hi, 

I used the example that you supplied. After navigating into the area, then trying to navigate back to Home, the page load fails due to the area name getting prepended to the url being built by the main menu.  ie the URL is /MyArea/Home (which doesn't exist) instead of just /Home.

How do you stop that from happening?

Thanks,

Rick

I found the solution when looking at the code for you demo:
 
public override void RegisterArea(AreaRegistrationContext context)
       {
           var razorRoute = context.MapRoute(
               "Razor_default",
               "razor/{controller}/{action}/{id}",
               new { controller = "Home", action = "FirstLook", id = "" });
            
           // The 'UseNamespaceFallback' token will allow the runtime to use the controllers defined outside the area
           razorRoute.DataTokens["UseNamespaceFallback"] = true;
 
           razorRoute.DataTokens[RazorViewToken] = true;          
       }

The line razorRoute.DataTokens["UseNamespaceFallback"] = true; keeps the route working for routes outside the area

I made an equivalent change and everything works OK.

Rick 
0
Daniel
Telerik team
answered on 26 Jan 2012, 01:20 PM
Hi Rick,

You could use either the UseNamespaceFallback DataToken or specify an empty string for the area route value when the controller is outside of an area. For example:
@Html.ActionLink("Go To Controller Out Of Area", "Index", "Home", new { area="" }, null)


Greetings,
Daniel
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
Tags
Grid
Asked by
raouf
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Rick
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or