using System; using System.Collections; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Linq; using System.ServiceModel.Syndication; //using System.ServiceModel.Web; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Text; using System.Xml; using System.Xml.Linq; public partial class Default3 : System.Web.UI.Page { public override void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/xml"; context.Response.ContentEncoding = System.Text.Encoding.UTF8; List items = new List(); SqlConnection objConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString); objConnection.Open(); string sql = "SELECT kood, pealkiri, kirjeldus, kuup FROM uudised ORDER BY kuup DESC"; SqlCommand objCommand = new SqlCommand(sql, objConnection); SqlDataReader objReader = objCommand.ExecuteReader(CommandBehavior.CloseConnection); while (objReader.Read()) items.Add( new SyndicationItem( objReader.GetString(1) , objReader.GetString(2) , new Uri(String.Format(@"http://veebistuudium.eneta.ee/ErkiSavisaar/RSS/NaitaUudist.aspx?id={0}", objReader.GetInt32(0))) , objReader.GetInt32(0).ToString() , new DateTimeOffset(objReader.GetDateTime(3)))); objReader.Close(); SyndicationFeed sf = new SyndicationFeed("Minu uudised" , "The site is the coolest bla bla and this rss feed is the best!" , new Uri("http://veebistuudium.eneta.ee/ErkiSavisaar/RSS"), items); XmlWriter rssWriter = XmlWriter.Create(context.Response.OutputStream); //Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(sf); Atom10FeedFormatter rssFormatter = new Atom10FeedFormatter(sf); rssFormatter.WriteTo(rssWriter); rssWriter.Close(); } }