Give the. NET site the RSS function

Source: Internet
Author: User

Add "General handler" under the root directory of the website with the suffix ". ashx"

The Code is as follows:

Code:
  1. <% @ Webhandler Language = "C #" class = "sample" %>
  2. Using system;
  3. Using system. Web;
  4. Using rsstoolkit;
  5. Public class sample: genericrsshttphandlerbase {
  6. Protected override void populatechannel (string channelname, string username)
  7. {
  8. // Add a channel
  9. Channel ["title"] = "sample channel ";
  10. // If the channel name is not blank
  11. If (! String. isnullorempty (channelname ))
  12. {
  13. // Set the channel name
  14. Channel ["title"] + = "'" + channelname + "'";;
  15. }
  16. // If the access user name is not blank
  17. If (! String. isnullorempty (username ))
  18. {
  19. // Set the user name
  20. Channel ["title"] + = "(generated for" + username + ")";
  21. }
  22. // Set other default channel attributes
  23. // Here is the RSS of the simple Reader
  24. Channel ["Link"] = "~ /Default. aspx ";
  25. Channel ["Description"] = "subscribe to this channel ";
  26. Channel ["TTL"] = "10 ";
  27. Channel ["name"] = channelname;
  28. Channel ["user"] = username;
  29. // Define items
  30. Genericrsselement item;
  31. // Create an item in a channel
  32. Item = new genericrsselement ();
  33. // Assign a value to the basic attribute of the item
  34. Item ["title"] = "complex ";
  35. Item ["descrption"] = "Full RSS Application complex RSS using rssdatasource ";
  36. Item ["Link"] = "complexrss. aspx ";
  37. // Add the item to the Channel
  38. Channel. Items. Add (item );
  39. // Create an item in a channel.
  40. Item = new genericrsselement ();
  41. Item ["title"] = "";
  42. Item ["Description"] = "";
  43. Item ["Link"] = "";
  44. Channel. Items. Add (item );
  45. }
  46. }

Add rsshyperlink to the navigateurl :~ /XX. ashx

OK, browsing Effect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.