Online Book Reader

Home Category

Programming Microsoft ASP.NET 4 - Dino Esposito [184]

By Root 5498 0

}

private HashTable GetBrowserInfoAsHashTable(String userAgent)

{

var values = new HashTable(180);

...

return values;

}

}

The final step consists of registering the new provider. You can do that declaratively through the section of the configuration file:

Alternatively, you can use the following code from global.asax:

void Application_Start(Object sender, EventArgs e)

{

HttpCapabilitiesBase.BrowserCapabilitiesProvider = new YourApp.CustomProvider();

}

When you write a provider, you should also consider caching the information because although it is static information, it might be requested several times. Setting up forms of data caching is entirely up to you.

The primary reason for writing a custom browser capabilities provider is to let developers store browser capabilities in an alternate repository (for example, a database) and use that instead of the built in one.

Note

The interface that defines the list of capabilities for browsers is fixed. For this reason, to add a new capability you can only resort to adding extra properties to the Capabilities dictionary of the HttpCapabilitiesBase class.

Search Engine Optimization


Spreading the word around about a Web site is a key step to getting a good site its deserved success. People visit a Web site because they are told about it, because they receive a direct link to it or, more likely, because they were searching for some topics related to the content of the site and engines such as Bing, Google, and Yahoo suggested they could find good information there.

If a Web site is quite high in the list of search results, the site is going to experience plenty of visits. How can you manage to make links from your site look attractive to search engines? That’s precisely a whole new field that goes side by side with Web development—search engine optimization or SEO.

SEO is critical for any Web sites that need to have high volumes of traffic to survive. More traffic will likely generate more advertising and increase the revenue the site generates.

Quick SEO Checklist


Search engines won’t tell you exactly which parameters they’re using to rank pages. Algorithms, however, are continually updated to stay in sync with user expectations and to fix any possible drawbacks that could cause inconsistent or unreliable results. Even though the indexing algorithm used by search engines remains a well-kept trade secret, it is widely known that pages with certain characteristics are ranked higher than others. Let’s review some of these SEO techniques.

The first aspect to consider is that the title of the Web page does matter. The title has to be unique for every page, kept short (about 50 characters maximum), and be meaningful enough to please both end users and search engines. To please search engines, the title string should include page keywords, preferably in the beginning of the string. In addition, the content of the title (or a similar string) should also be displayed through an

tag. This increases the relevance of the content to the search engine’s eyes.

Search engines work by searching references to Web pages that can be associated with the input keywords. In other words, a search engine works by mapping its own keywords to the content exposed by pages. HTML pages can include a couple of interesting meta tags in their section. These meta tags are keywords and description:

...

In ASP.NET 4, you can set the keywords and description attributes easily through a pair of new properties added to the Page class. (See Chapter 5.) Today, however, the importance of the keywords meta tag is diminished. Bing and Google, for example, have both stated explicitly that they don’t use keywords declared in the of the page but actually

Return Main Page Previous Page Next Page

®Online Book Reader