asp.net mvc中的sitemaps.xml

我的网站有动态内容,正在创建新链接。

我的数据库有一个表,它几乎包含所有添加的URL。

所以我的问题是如何使用sitemaps.xml来获取importnt,还有一种简单的方法来构建它,以便在生成新链接时我可以将它标记到sitemap.xml文件的末尾吗?

您可以使用LINQ to XML从数据库创建XML站点地图,然后通过返回Content(document.ToString(), "text/xml")从操作返回站点地图。

抓取工具能够更快,更准确地抓取您的网站非常重要。

您可以创建一个控制器,比如siteMapController,并在索引中添加以下内容

  public ActionResult Index() { var xmlString = ""; xmlString += "" + "Your site" + "weekly" + "0.6" + "" + "" + "Static Link of you site" + //you can add as many you want "weekly" + "0.6" + "" + ""; //Dynamic links xmlString += "" + "Link of new item"" + "" + DateTime.Now.ToString("yyyy-MM-dd") + "" + "daily" + "0.8" + ""; } xmlString += ""; ViewData["siteMap"] = xmlString; return View(); } 

将xml保存在您的服务器上并通过此链接发布站点地图

https://www.google.com/webmasters/tools/home?hl=en

希望有所帮助