This project is read-only.

Best way to access QueryString from driver

Topics: Customizing Orchard, General, Writing modules
Jun 28, 2011 at 1:21 AM

So I'm writing a module that has a ContentType that uses Routable for its URL, so I don't want to create my own custom controller + route provider (which it looks like I would have to do).

I do want to have paging, however, and I'm wondering what the best way to go about accomplishing that would be.  Every example utilizing the pager that I see in the source is using its own custom controller to get at the paging querystring parameters.

What I'm doing now is injecting a WorkContextAccessor into my driver and directly accessing the HttpRequest as such: 

var workContext = _workContextAccessor.GetContext();
var request = workContext.HttpContext.Request;
if (request.QueryString["page"] != null)
   pageNumber = Convert.ToInt32(request.QueryString["page"]);

And then injecting the pager shape into my driver result.  Is there a better way to do this?