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

[Solved] RenderAction Strangeness

3 Answers 136 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.
Stefan
Top achievements
Rank 1
Stefan asked on 15 Aug 2011, 06:50 PM
Hello!

If a Grid is rendered via RenderAction with additional RouteValues additional gibberish is added to the URL for the grid actions.

Example:

Index.cshtml
@{ Html.RenderAction("Grid""Task"new { Test = "Test" }); }

Task/Grid
[ChildActionOnly]
public ActionResult Grid()
{
    return View("Grid", GetGridViewModel(TaskGridSelectMode.All));
}

Grid.cshtml
@model TaskGridViewModel
           
@{ Layout = null}
 
@(Html.Telerik().Grid(Model.Data).Name("tasks") (additional yadda yadday omitted)

URL after clicking on Edit:
http://localhost/ALI/Task/All/1?Test=Test&bd5d2b76-cd5d-4a68-8e7c-51a6f9fc2a6f=System.Web.Mvc.DictionaryValueProvider`1%5BSystem.Object%5D&tasks-mode=edit

Wait, what? Where did that ValueProvider-stuff come from?

I have honestly no idea and the only way to fix this is to remove the additional RouteValues from the RenderAction call, which in my case is NOT an option.

3 Answers, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 16 Aug 2011, 11:06 AM
Hello Stefan,

The additional values are added by the RenderAction to the RouteData values. This can be verify by looking into the RouteData in the "child" view:

@foreach (var data in ViewContext.RouteData.Values)
{
    @data.ToString()<br />
}

As you may know when grid builds its URLs, the current RouteData is merged will the additional parameters, this is why the generated URL looks as you have described.

I hope this information is helpful.

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
Stefan
Top achievements
Rank 1
answered on 17 Aug 2011, 10:03 PM
True, looks like it's either my or ASP.NET's fault. I don't quite get how this is happening.

Edit:
After a quick test in a blank project this seems to be MVC's fault. For "child requests" it adds an DictionaryValueProvider to the RouteData.Values.

Or it is by design.
Or I'm doing something horribly wrong with Html.RenderAction.
Or all of the above.
0
cheburek
Top achievements
Rank 1
answered on 02 Oct 2011, 12:02 AM
Hello!

My grids in Child actions don't have paging but I also stuck with the same problem...

Actually this bug was found by ... googlebot. 
1. It crawls grid's urlFormat property value as a real url and then tries to get page via GET request from that url. Of course there is no any page and asp.net throws an exception.
2. related to the previous issue but it is possible to reproduce it on first level views. Googlebot founds in the page source an url like     urlFormat:'/en/Artists/Title?page=%7B0%7D&size=70'  

Actually the problem with that template page value because again googlebot after that requests server with found url and if you have in your controller  method page parameter declared as int then you also get get exception because it will receive the string '  %7B0%7D'. Bams!

As one of possible solutions for both issues IMHO could be preventing rendering in html full url. It could be something like
urlFormat:'/ru/Artists/Title' + '?page=%7B0%7D&size=70' (split with space) or separate every parameter.

Is that possible to have a similar (or another) workaround in current version?
Thank you
Tags
Grid
Asked by
Stefan
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Stefan
Top achievements
Rank 1
cheburek
Top achievements
Rank 1
Share this question
or