Querystring in Admin menu

Topics: Customizing Orchard, Writing modules
Jul 4, 2012 at 1:02 PM

Hey Everyone,

I'm looking for a way to instert a querystring for filtering contentitems

I have a list of schools (content items) which are presented like this int the backend:


Somewhere in my code I do a redirecttoaction like this:

return RedirectToAction("List", "Admin", new { area = "Contents", id = "School", });

Now I want to add a querystring so I get only the schools who are located in a specific city


Is that possible and how can I construct the querystring to return something like "where School.CityRecord.Id == CityId

CityId will also be a variable that comes from my code.



Jul 5, 2012 at 3:21 AM

If I'm not mistaken, if you add properties to that anonymous objects that the system can't relate to known route tokens, it will just add them as querystring parameters.

Jul 5, 2012 at 10:53 AM


I don't understand, I'm looking for something like http://localhost:30320/OrchardLocal/Admin/Contents/List/School&CityName=CityName

How can I accomplish that?


Jul 5, 2012 at 10:17 PM
Edited Jul 5, 2012 at 10:17 PM

As Bertrand mentioned, you can just add another property to the anonymous object that you are passing as the 3rd argument, like this:

return RedirectToAction("List", "Admin", new { area = "Contents", id = "School", CityName = "Sidney" });

However, I don't think the Contents controller will know what to do with that extra parameter, so nothing special will happen. If you want to handle this extra filter, you can create your own admin controller in your own module. Although I'm not quite sure, I believe that 1.5 will enable you to create customized query views straight from the admin. Then again, I may be mistaken.

Jul 6, 2012 at 9:51 AM


Thanks, I've already tried that and like you said nothing happens because the controller doesn't know what to do with it, Do you think I can add some code to my schooldriver for that? I would like to use the system already present for the backend, it seems a bit much to rewrite the whole thing, I would also like to add custom filtering in the backend (like a dropbox to filter on the cities) Do you think that's possible or should I wait till 1.5? (do you know when that will be released?)


Jul 11, 2012 at 3:15 PM

Why don't you implement your own controller?

Jul 11, 2012 at 5:48 PM


Can I create my own controller and still link in to the dashboard system of Orchard?

It seems a bit much to rewrite the whole thing just to filter on something.


Jul 11, 2012 at 6:09 PM

Of course. There is nothing magical about existing controllers and admin menu items.