Description:I have a website developed using asp.net mvc (c#) which contains some static pages and also some dynamic pages i.e where the content is fetched from database and is dynamically increasing as well, So I need to build such a sitemap for which I need to code for once and it take care of the future items that needs to be included in the sitemap.
Posted by: Khalid Abbas | Posted on: Jan 21, 2020
6
Step 1 – Create A CustomSitemapItem Class
The CustomSitemapItem Class will be used to store all the properties we need for each sitemap URL entry.
Step 2 – Create A CustomSitemapActionResult
The CustomSitemapActionResult is the result that comes back from the controller when the URL /sitemap is called. It takes a list of CustomSitemapItem classes and generates the corresponding xml file that will be used by different search engines to index your website.
Step 3 – Create A Sitemap Controller Method
The controller is where you will generate your list of CustomSitemapItem classes that will be returned via the CustomSitemapActionResult
That’s it now you can simply use the controller method Sitemap() to get your sitemap xml.
Replied by: Tabish Usman | Replied on: Mar 09, 2020