What are the best methods for implementing a Google hashbang / Ajax crawl pattern using ASP.NET MVC?
http://code.google.com/web/ajaxcrawling/docs/getting-started.html :
the crawler will change every AJAX URL such as
www.example.com/ajax.html
to temporarily become
www.example.com/ajax.html?_escaped_fragment_=key=value
The ASP.NET routing structure does not allow you to specify query string parameters, but of course you can always create an action method that takes _escaped_fragment_ as a parameter (or even just searches for the _escaped_fragment_ parameter in the request header).
This is a little cumbersome. Is there a better way?
UPDATE:
I went ahead and implemented the following pattern (in my case, the fragments look like a regular URL). Again, this is hardly the cleanest approach, so any suggestions are welcome.
public virtual ActionResult Index(int id, string _escaped_fragment_) { //Handle Google Ajax Crawler if (_escaped_fragment_ != null) { string[] fragments = _escaped_fragment_.Split(new char[]{'/'}, StringSplitOptions.RemoveEmptyEntries); if (fragments.Length > 0) { //parse fragments //return static content } } //normal action operation return View(); }
Oskar austegard
source share