This project is read-only.

Cannot use query parameter to select category.

Aug 17, 2012 at 6:33 PM

When I try to do:

It does not work. 

Aug 17, 2012 at 9:15 PM

You calling default page and passing it id. Page has no idea what this id means - blog? post? category? something else? So it ignores it and loads posts as usual. 

Aug 17, 2012 at 11:08 PM
Edited Aug 17, 2012 at 11:09 PM

I have tried " category= " also. I was using the id query parameter because that is what is used in the DisplayCategories method .  

I think there is something wrong with the code. I have a workaround.

I hacked up a new method called DisplayByCategory and placed in the the default.aspx.cs, after the DisplayCategories method.  



private void DisplayByCategory()
        if (!String.IsNullOrEmpty(Request.QueryString["cat"]))
            Category tradeCategory = Category.Categories.Find(
                delegate(Category c)
                    string foo = Request.QueryString["cat"];
                    return c.Title == foo;

            if (tradeCategory != null)
                PostList1.Posts = tradeCategory.Posts.ConvertAll(
                    new Converter(delegate(Post p)
                        return p as IPublishable;



Also, in the ... Page_Load



 if (Request.RawUrl.ToLowerInvariant().Contains("/category/"))
//this new stuff

 else if (Request.QueryString["cat"] != null)

//end new stuff

        else if (Request.RawUrl.ToLowerInvariant().Contains("/author/"))
Aug 18, 2012 at 1:48 AM

I'm a little at lost. The way you load category is:

Why do you need to work around it?

Aug 18, 2012 at 6:28 PM

The problem is that I could not select the theme and category at the same time. I describe the problem in the following post:

Intuitively, I wanted to use

That did not work, so I tried to combine parameters with &

Aug 19, 2012 at 7:01 AM

What do you mean "not working"? For example, if you try link below you'll see that theme changes from normally used "boldy" to "standard". It doesn't do it in your case or you expect it to do something different?

Aug 19, 2012 at 9:27 PM

I am not sure exactly why it is not working but when I combine the url routing and query parameter like: ... the theme changes to bar, but the posts are not all in the category of foo.


If I do ... that makes all of the posts in category show the foo category. It is different behavior if the query parameter is added

Aug 19, 2012 at 9:34 PM

I checked out your example( and it looks like you do not have the same behavior.


I modified my version of BE as a result of fixing another problem described in the following post: 


Maybe that is the problem?

Aug 20, 2012 at 5:33 PM


If it helps at all, here is some more information: --- changes the theme, but does not show foo as the category --- it also shows "" in the address bar. The id number shown is the CategoryID of the category foo. Foo is not selected as the category, but the theme is selected. Very strange, could it have something to do with the modifications made to set the theme cookie? 
Aug 20, 2012 at 7:00 PM

It shouldn't, but you can remove that modification, which is just a few lines of code, and see if it changes behavior.