Hi,
My question is: Can I use my routing variables as a response. I.E. rather that redirecting to url can I redirect the response to an IHttpHandler instead?
I ask because I want to redirect users who perform site searches to a single results page in the "pass" subdomain ("http://pass.myweb.co.uk") and I want to know if there is a better way than specifying a URL.
Exposition to follow:
So I have a custom
RouteHandler
that manages all of my urls, pages and page queries. I have several subdomains, each with their own Page lists, each page may have a page list and / or a query handler list. This makes queries a lot easier to handle and is a great way to manage my pages.
At some point I would like to include these handlers in a db table or two. That way I can create a web interface to manage them, so I'm foreseeing a full CMS comming out of this one day.
Here are some examples:
SubDomain Handler Usage:
private static SubDomainHandler passSubDomainHandler()
{
return new SubDomainHandler("pass",
getPassRootHub(),
getPassClaimRefPageHandler(),
getSearchResultsPageHandler()
);
}
You may be keen to see what the classes
SubDomainHandler, PageHandler & QueryHandler
actually do, but trust me, it's dull as dish water.
Search Results PageHandler:
private static PageHandler<Pages.Search.SearchResults> getSearchResultsPageHandler()
{
return new PageHandler<Pages.Search.SearchResults>(
"SearchResults",
getSearchResultsQueryHandler());
}
As with the SubDomainHandler, a number of pages can be included in the constructor, each would be a URL after "SearchResults". We can also use QueryHandlers at this stage which do some cool stuff.
QueryHandler:
private static QueryHandler<Pages.Search.SearchResults> getSearchResultsQueryHandler()
{
return new QueryHandler<Pages.Search.SearchResults>(
@"[\d\w]+"
);
}
In this case I have a generic query handler. Any text after the SearchResults/ url will be the search text. If I have other URL routes after this URL I can instead use the text "Keyword_[\d\w]". This ensures that there is no ambiguity in the URL paths. If that was the case then the page would have a
Page.RouteData.Values["Keyword"]
. This is a generic query so there is a
Page.RouteData.Values["Parameter"]
by default.
My plan is to have wonderfully hackable URLS. My favorite query handler handles dates so the URL "web.co.uk/Data/2015/05/16" returns the full date range in the RouteData, even if you miss off the day or the day and the month!