banner



How To Add Rss Feed In Asp Net Website

  • Updated appointment Feb 11, 2021
  • l.3k
  • 0

RSS Feed generally use to return the output in plain text or xml Format.

An RSS Feed is generally used to return the output in patently text or XML format.

To parse the results from our application we use the RSS feed result that can exist hands parsed.

Nosotros accept a tag format for the RSS.

It'due south main tag is the channel tag:

<channel> </channel>

The other tags inside the channel tag are title, link and description.

Title tagThe name of the channel is similar to the championship of a website or web page.

Instance: Brand RSS Feeds

Tag: <title></title>

Link tagThe URL to the HTML website.

Example: http://www.brand-rss-feed.com

Tag: <link></link>

Description TagThe phrase(s) or sentence(south) describing the content of the unabridged feed.

Example: Details RSS feed creation in a pace-by-step style

Tag: <clarification></description>

All together they look similar:

  1. <HeaderTemplate>
  2.            <rss version="two.0" >
  3.                 <channel>
  4.                     <title>RSS Example</title>
  5.                     <link>http:
  6.                     <description>
  7.                     RSS For Commodity
  8.                     </description>
  9. </HeaderTemplate>

Now to create a RSS in ASP.Net.

STEP one

Create a new RSS.aspx page and remove all the HTML markup from RSS.aspx.

The code will look like:

  1. <%@ Page Linguistic communication= "C#"  ContentType= "text/xml"  AutoEventWireup= "true"  CodeBehind= "RSS.aspx.cs"  Inherits= "AndroitWebApp.RSS.RSS"  %>

STEP ii

At present add together a Repeater Command on the page:

  1. <%@ Page Linguistic communication= "C#"  ContentType= "text/xml"  AutoEventWireup= "true"  CodeBehind= "RSS.aspx.cs"  Inherits= "AndroitWebApp.RSS.RSS"  %>
  2. <asp:repeater ID="RSS"  runat= "server" >
  3. </asp:repeater>

Step 3

Selection query string values for the variables:

  1. protected void  Page_Load( object  sender, EventArgs eastward)
  2. {
  3. int  SVID = Convert.ToInt32(Request[ "SVID" ].ToString());
  4. int  RVID = Convert.ToInt32(Request[ "RVID" ].ToString());
  5.     GetChatmsg(SVID,RVID);
  6. }

Now become to the RSS.aspx.cs and create a function to demark data from the database:

  1. protected void  GetChatmsg( int  SVID, int  RVID)
  2. {
  3. try
  4.     {
  5. using  (SqlCommand cmd = new  SqlCommand())
  6.         {
  7.             cmd.CommandText ="spr_Visitor_View_UserChatMsgs" ;
  8.             cmd.Parameters.AddWithValue("@SVID" , SVID.ToString());
  9.             cmd.Parameters.AddWithValue("@RVID" , RVID.ToString());
  10.             RSS.DataSource = DBHelper.SqlExecuteReader(cmd);
  11.             RSS.DataBind();
  12.         }
  13.     }
  14. catch  (Exception ex)
  15.     {
  16. throw  ex;
  17.     }
  18. }

Here nosotros used the DBHelper class for the SQL Connection.

DBHelper.cs

  1. public class  DBHelper
  2. {
  3. private  DBHelper()
  4.     {
  5.     }
  6.     #region Connection String
  7. private static string  conn = "Data Source=SQL6; uid=sa; pwd=SQL@345; Initial catalog=NewApp" ;
  8.     

0 Response to "How To Add Rss Feed In Asp Net Website"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel