适用于 ASP.NET 3.5 Web 应用程序项目的可更新 Google Sitemap

发布于 2024-08-19 16:13:03 字数 1570 浏览 6 评论 0原文

我正在使用 C# 开发 ASP.NET 3.5 Web 应用程序项目。我手动添加了一个 Google 友好的站点地图,其中包含项目中每个页面的条目 - 这不是 CMS。

  <url>
    <loc>http://www.mysite.com/events.aspx</loc>
    <lastmod>2009-11-17T20:45:46Z</lastmod>
    <changefreq>daily</changefreq>
    <priority>0.8</priority>
  </url>

客户端使用管理后端更新事件。除此之外,该网站相对静态。我正在尝试确定更新的最佳方法。定期更新的少数页面的值。

特别是,我使用 ListView 控件的 QueryStringField 来增强 SEO,如下所述:

https://web.archive.org/web/20211029044137/https://www.4guysfromrolla.com/articles/010610-1.aspx

http://gsej .wordpress.com/2009/05/31/using-a-datapager-with-both-a-querystringfield-and-renderdisabledbuttonsaslabels/

当设置 QueryStringField 属性时,DataPager 将分页界面呈现为一系列爬虫可以跟踪并索引的超链接。但是,如果 Google 两天前抓取了我的事件列表,同时管理员添加了另外十几个事件……假设页面大小设置为 6;在这种情况下,Google SERP 链接现在将指向错误的页面。这就是为什么我需要确保站点地图在事件页面发生更改时立即反映出来。

我已经查看了其他问题以获取信息,但没有找到我需要的内容。任何人都可以提供一些指导或替代方法吗?

更新:

由于这是一个共享托管环境,目录观察器/服务将无法工作:

如何在共享虚拟主机环境中创建文件观察器

更新:

开始意识到我可能需要向 Google 表明包含的页面已已更新;更新最后修改的 HTTP 标头?

I am working on an ASP.NET 3.5 Web Application project in C#. I have manually added a Google-friendly sitemap which includes entries for every page in the project - this is not a CMS.

  <url>
    <loc>http://www.mysite.com/events.aspx</loc>
    <lastmod>2009-11-17T20:45:46Z</lastmod>
    <changefreq>daily</changefreq>
    <priority>0.8</priority>
  </url>

The client updates events using an admin back-end. Other than that, the site is relatively static. I'm trying to decide on the best way to update the <lastmod> values for a handful of pages that are regularly updated.

In particular, I am using the QueryStringField of the ListView control to enhance SEO as described here:

https://web.archive.org/web/20211029044137/https://www.4guysfromrolla.com/articles/010610-1.aspx

http://gsej.wordpress.com/2009/05/31/using-a-datapager-with-both-a-querystringfield-and-renderdisabledbuttonsaslabels/

When the QueryStringField property is set, the DataPager renders the paging interface as a series of hyperlinks which the crawler can follow and index. However, if Google has crawled my list of events two days ago, and in the meantime, the admin has added another dozen events... say the page size is set to 6; in this case, the Google SERP links would now be pointing to the wrong pages. This is why I need to be sure that the sitemap reflects changes to the events page as soon as they happen.

I have already looked though other SO questions for info and didn't find what I needed. Can anyone offer some guidance or an alternative approach?

UPDATE:

Since this is a shared hosting environment, a directory watcher/service won't work:

How to create file watcher in shared webhosting environment

UPDATE:

Starting to realize that I may need signify to Google that the containing page has been updated; update the last-modified HTTP header?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不再见 2024-08-26 16:13:03

不要使用手动编码的站点地图,而是创建一个站点地图处理程序来动态生成站点地图。您可以在处理程序中创建一个方法,该方法将从现有的导航站点地图、数据库甚至硬编码的页面列表中抓取页面。您可以从列表中创建 XmlDocument,并将文档的 InnerXml 写入处理程序响应流。

然后,使用一个方法创建一个类,该方法将使用上述处理程序的 URL 自动 ping 搜索引擎(例如 http://www.google.com/webmasters/tools/ping?sitemap=http://www.mysite.com/sitemap.ashx )。

每当有人添加新事件时,都调用上面的方法。这将使用您最新的站点地图(通过上述方法新生成)对 Google 执行 ping 操作。

您需要确保 ping 仅在站点地图实际更新时才起作用。您可以在 AddNewEvent 处理程序中对 events.aspx 使用 File.SetLastWriteTime 来表示包含的页面已更新。

另外,请小心确保过去一小时没有 ping(因为 Google 指南不鼓励每小时 ping 多次)。

我实际上计划在以下 OSS 项目中实现这一点:http://cyclemania.codeplex.com。完成后我会通知您,您可以查看。

Rather than using a hand-coded sitemap, create a sitemap handler that will generate the sitemap on the fly. You can create a method in the handler that will grab pages from an existing navigation sitemap, from the database, or even from a hard-coded list of pages. You can create an XmlDocument from the list, and write the InnerXml of the document out to the handler response stream.

Then, create a class with a method that will automatically ping search engines with the above handler's URL (like http://www.google.com/webmasters/tools/ping?sitemap=http://www.mysite.com/sitemap.ashx).

Whever someone adds a new event, call the above method. This will ping Google using your latest sitemap (freshly generated by the above method).

You want to make sure that the ping only works if the sitemap has actually been updated. You could use File.SetLastWriteTime on events.aspx in the AddNewEvent handler to signify that the containing page has been updated.

Aslo, be careful to make sure there have been no pings for the last hour (as Google guidelines discourage pinging more than once per hour).

I actually plan to implement this in the following OSS project: http://cyclemania.codeplex.com. I will let you know once it's done and you can have a look.

红颜悴 2024-08-26 16:13:03

如果您让用户向网站添加事件,您可能正在使用数据库。
这意味着您可以在运行时生成 XML 站点地图,如下所示:

  • 创建一个可用站点地图的页面(不需要是 sitemap.xml,也可以是 sitemap.aspx 甚至 sitemap.ashx)。
  • 打开所有记录的数据库连接
  • 循环,并为每条记录创建一个 Xml 元素

此博客文章应该可以进一步帮助您:用 C# 构建搜索引擎站点地图
它没有使用 .Net 3.5 中的新 XElements,但可以正常工作。

您可以将其放在 aspx 页面中,但添加 HttpHandler 可能会更好,如同一博客不同帖子中所述:(为站点地图创建 httphandler)

If you let your user add events to the website you are probably using a database.
This means you can generate the XML-Sitemap at runtime like this:

  • create a page where your sitemap will be available (this doesn't need to be sitemap.xml but can also be sitemap.aspx or even sitemap.ashx).
  • open a database connection
  • loop through all records and create an Xml Element for each record

This blog post should help you further: Build a Search Engine SiteMap in C#.
It is not using the new XElements from .Net 3.5, but is will work fine.

You can put this in an aspx page, but adding an HttpHandler is probably better as described on the same blog, different post: (creating a httphandler for a sitemap)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文