Nesse tutorial você irá ver como gerar Sitemap através de uma página asp.net. 

1-) Referencie o assembly DotNetMax.Web.SitemapGenerator 

2-) Criar uma página (Ex: GeraSiteMap.aspx) 

3-) No código C#, vamos colocar 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetMax.Web.SitemapGenerator.Interface;
using DotNetMax.Web.SitemapGenerator.Model.Enum;
namespace DemoWebCSharp.Demo.GerandoComPagina
{
  public partial class GeraSiteMap : System.Web.UI.Page
  {
    protected void Page_Load(object sender, EventArgs e)
    {
      // Inicializa o Objeto de Geração de Sitemap
      ISitemapEngine sitemapEngine = new DotNetMax.Web.SitemapGenerator.Provider.SitemapProvider().
GetEngine(eEngineAvailables.XMLSiteMap_Version_09);
      // Adiciona as Entradas de Sitemap no Componente de Geração (Para maiores informações sobre os parâmtros, consulte a documentação OnLine)
      sitemapEngine.AddURL("http://www.meusite.com.br/Default.aspx");
      sitemapEngine.AddURL
("http://www.meusite.com.br/Demo/GerandoComPagina/GeraSiteMap.aspx", new DateTime(2010, 04, 10), DotNetMax.Web.SitemapGenerator.Model.Enum.eChangeFrequence.Daily, DotNetMax.Web.SitemapGenerator.Constant.URLPriority.Normal);
      // Limpa Qualquer tipo de Resposta que a Página já tenha Enviado para o Buffer de Saída
      this.Response.Clear();
      this.Response.ClearContent();
      this.Response.ClearHeaders();
      // Configura o Content-Type
      this.Response.ContentType = "text/xml";
      // Envia a Responsta para a Página
      sitemapEngine.GenerateToStream(this.Response.OutputStream);
      // Finaliza o Buffer de Response
      this.Response.Flush();
      this.Response.Close();
    }
  }
}

< Voltar

Page last updated on 10/04/2010 at 10:31 PM
znjdb32s6g