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:
- <HeaderTemplate>
- <rss version="two.0" >
- <channel>
- <title>RSS Example</title>
- <link>http:
- <description>
- RSS For Commodity
- </description>
- </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:
- <%@ 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:
- <%@ Page Linguistic communication= "C#" ContentType= "text/xml" AutoEventWireup= "true" CodeBehind= "RSS.aspx.cs" Inherits= "AndroitWebApp.RSS.RSS" %>
- <asp:repeater ID="RSS" runat= "server" >
- </asp:repeater>
Step 3
Selection query string values for the variables:
- protected void Page_Load( object sender, EventArgs eastward)
- {
- int SVID = Convert.ToInt32(Request[ "SVID" ].ToString());
- int RVID = Convert.ToInt32(Request[ "RVID" ].ToString());
- GetChatmsg(SVID,RVID);
- }
Now become to the RSS.aspx.cs and create a function to demark data from the database:
- protected void GetChatmsg( int SVID, int RVID)
- {
- try
- {
- using (SqlCommand cmd = new SqlCommand())
- {
- cmd.CommandText ="spr_Visitor_View_UserChatMsgs" ;
- cmd.Parameters.AddWithValue("@SVID" , SVID.ToString());
- cmd.Parameters.AddWithValue("@RVID" , RVID.ToString());
- RSS.DataSource = DBHelper.SqlExecuteReader(cmd);
- RSS.DataBind();
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
Here nosotros used the DBHelper class for the SQL Connection.
DBHelper.cs
- public class DBHelper
- {
- private DBHelper()
- {
- }
- #region Connection String
- private static string conn = "Data Source=SQL6; uid=sa; pwd=SQL@345; Initial catalog=NewApp" ;
0 Response to "How To Add Rss Feed In Asp Net Website"
Post a Comment