[Seo] enables your ASP. NET Website to automatically generate sitemap -- xmlsitemap

Source: Internet
Author: User

First, I want to explain: Asp. net built-in sitemap is completely different from the sitemap mentioned here, Asp. the sitemap in net is mainly used for user navigation, and the sitemap mentioned here is used to guide search engine crawlers.

Let's take a look at the official explanation:

What is sitemap?

Sitemap allows administrators to easily notify the search engine of webpages available for crawling on their websites. The simplest form of sitepmap is the XML file, list the websites in the website and other metadata about each website (the last update time, the frequency of changes, and the importance to other websites ), so that the search engine can capture websites more intelligently.

Web crawling tools usually search for webpages through links on the website and other websites. Sitemap provides this data so that all URLs provided by sitemap can be captured by the crawling tool of sitemap and the URLs using the relevant metadata can be learned. Using the sitemap protocol does not guarantee that web pages are included in search engines, but some tips can be provided to Web crawling tools so that they can capture websites more effectively.

Sitemap 0.90 is provided according to the attribution-sharing alike Creative Commons license clause, and is widely used by Google and Yahoo! And support from many vendors, including Microsoft.

Introduced from sitemaps.org:Http://www.sitemaps.org/zh_CN/

To sum up, providing sitemap is a way to assist search engine crawlers in indexing websites. Without sitemap, your website will be indexed, with sitemap, it will be more comprehensive and accurate.

In addition to providing websites, the most important thing is to provide the page update timestamp, website focus, and update return visit frequency suggestions, so that search engine can more accurately grasp your website.

How to automatically generate sitemap?

There are already many ready-made generators:

Http://code.google.com/p/sitemap-generators/wiki/SitemapGenerators

Http://www.google.com/support/webmasters/bin/answer.py? Answer= 34634

However, there is no official generation tool in ASP. NET, and the search for "ASP. NET sitemap" is also found on a large number of ASP. NET built-in sitemap functions.

Therefore, I want to implement an ASP. NET sitemap generation tool by myself. And I hope this tool can work with ASP. net synchronous interaction for data updates to ensure the timeliness of data; while most other generators are like a private crawler, You need to manually release it to crawl your website, to generate the whole site sitemap. I do not like this.

Xmlsitemap

This is my implemented sitemap generation tool. The implementation method is as follows:

    1. Store site, page set, and page data through a database:
    2. When adding, deleting, and modifying data on an ASP. NET Website, call the method published by the site map to update the database data.
    3. Output sitemap in XML format through ashx for search engine crawlers to read.

InArticleAt the end of the project, I will share the download link for this project. Next I will explain how to use this project.

How to deploy it?

I will provide the following files to deploy this function on an existing ASP. NET Website:

First, you must reference xmlsitemap. dll.

Then, add xmlsitemap. ashx. CS and xmlsitemap. ashx to the project through "add existing items.

Add sitemap. MDF to the app_data directory of the project through "add existing items.

Specify the database connection string of sitemap. MDF in Web. config:

<Connectionstrings>

< Add Name = "Mysitemapdataconnstr" Connectionstring = "Data Source =. \ sqlexpress; attachdbfilename = 'C: \ Users \ skyd \ Documents \ Visual Studio 2008 \ projects \ Lab \ Webapplication10 \ webapplication10 \ app_data \ sitemap. MDF '; Integrated Security = true; user instance = true" />

</Connectionstrings>

Add a new global. asax file in the project (if this file is not created before) and initialize it in application_start:

The blue highlighted part is the database connection string of sitemap. MDF specified in Web. config;

The highlighted yellow part is your website name. This string is used each time you submit data;

The green highlight part is the URL of your site. Each new URL data must be under this URL domain name.

How to use it?

We will use a button to simulate the operation of adding data:

Protected VoidButton#click (ObjectSender,EventargsE)

{

VaRID=Guid.Newguid ();

Site Map . Add page ("Mysite", ID,Path.Combine ("Http://www.MySite.com /","Page. aspx? Id =" +ID ),0.5, Update frequency . Every day );

}

Note: This is only used for testing, so a guid is generated temporarily to pass in the site map. In actual use, it should be passed in with the guid of your original data entry, because you will probably update and delete it later. If you want to reflect it to the site map at the same time, you must also use its guid as the identifier, to find it.

When you click this button frequently, multiple data entries are added to the site map. You can access xmlsitemap. ashx? Site = mysite:

The URL address is the URL of the page set. Because the page data volume does not reach the upper limit of the page set, there is only one page set currently.

Visit the URL of the page set:

 

Here is the detailed address and related information list for each page.

In addition to adding data, there are also methods for updating and deleting data, because they are all written in Chinese.CodeIt is easy to understand and will not be demonstrated here:

Download Resources

Deployment file: http://www.uushare.com/user/icesee/file/1893271

Sample website projectSource code: Http://www.uushare.com/user/icesee/file/1893269

Xmlsitemap source code: http://www.uushare.com/user/icesee/file/1893270

XPS version: http://www.uushare.com/user/icesee/file/1895946 in this article

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.