技术开发 频道

在ASP.NET Web应用中创建GeoRSS订阅源

  11. 在注释 Use columns 0 and 1 for the title and description下,添加以下代码以根据存储过程返回的数据创建 ", geomRdr.GetValue(0)))

  rssOutput.AppendLine(String.Format("{0}", _

  geomRdr.GetValue(
1)))

  12. 在注释 Add a element下,添加以下代码来为此条目创建 元素。

  rssOutput.AppendLine("")

 

  13. 在注释 Get the geography instance GML from column 2下,添加以下代码,以从存储过程结果中检索 GML 数据。

 

  gml = geomRdr.GetValue(2).ToString()

   14. 在注释 Add the elements to the output XML下,添加以下代码以向 GeoRSS 订阅源添加 GML 数据。

  rssOutput.AppendLine(gml)

   15. 在注释 Close and elements下,添加以下代码。 

  rssOutput.AppendLine("")

  rssOutput.AppendLine(
"")

   16. 在注释 Close the document and send it as the response下,添加以下代码以完成 GeoRSS 订阅源并将其发送给请求人。

  rssOutput.Append("")

  context.Response.Write(rssOutput.ToString())

   17. 保存 GeoRSSHandler.vb。

  注册 HTTP 处理程序

  1. 在解决方案资源管理器中,双击 web.config 在编辑器中打开它。

  2. 在 部分中,在注释 Register the GeoRSSHandler for .georss requests下,添加以下 XML。

<add verb="*" path="*.georss" type="GeoRSSHandler" validate="false"/>

   注意:您必须为特定文件扩展名注册 HTTP 处理程序,以便 Internet Information Services 将针对这些文件的请求转发到正确的处理程序。

  3. 保存 web.config。

  测试 HTTP 处理程序

  1. 在解决方案资源管理器中,单击位于树的根目录下的网站项目文件,然后按 F4 查看其属性。

  2. 请注意观察端口号属性。

  3. 在网站菜单上,单击启动选项。

  4. 选择启动 URL,输入以下 URL(将 port 替换为网站的端口号属性的值),然后单击确定。

  http://localhost:/storefindersite/test.georss

  5. 在调试菜单上,单击开始执行(不调试)。

  6. 当 Microsoft Internet Explorer ® 打开时,查看包含商店名称的 RSS 订阅源的页面。

  7. 在 Internet Explorer 中,右键单击该网页的任意位置,然后单击查看源文件以在记事本中打开该页的源文件。请注意,该页的源是您前面创建的 HTTP 处理程序生成的 GeoRSS 订阅源。

  8. 关闭记事本。

  9. 在 Internet Explorer 中的地址栏中,将以下查询字符串附加到 URL 后,然后按 Enter。

  ?SearchFrom=34.000000,-118.000000

  10. 验证生成的 GeoRSS 订阅源包含搜索区域及其中的所有商店。

  11. 关闭 Internet Explorer。

0
相关文章