DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

Creating RSS Feeds with Razor

 10 Replies
 1 Subscribed to this topic
 40 Subscribed to this forum
Sort:
Page 1 of 212 > >>
Author
Messages
New Around Here
Posts: 8
New Around Here
New Poster
New Poster
Congrats on posting!

Hello DNN Doctors!

I have a question. I'm trying to use Razor to create RSS Feeds. There's been quite a bit of trial and error but the code below is now rendering correctly:

@{
    Layout = null;
    Response.ContentType = "application/rss+xml";
    var db = Database.Open("SiteSqlServer");
    var dbData = "STORED PROCEDURE CODE HERE";
}

   
        FEED TITLE
       
            IMAGE URL
            IMAGE TITLE
            WHERE IMAGE LINKS TO
       
        FEED DESCRIPTION
        60
        @foreach (var row in db.Query(dbData))
        {
            @:
                @row.title
               
                @:
                    @row.link
                @:
                @row.guid
            @:

        }
   

The problem I'm having is that all of the DNN gobbledy-gook is rendering as well so it doesn't display as an actual RSS Feed eventhough I'm changing the ContentType in the code. I believe this has something to do with my skin file as its still referencing the skinning engine. Here is that code:

<%@ Control language="vb" AutoEventWireup="false" Explicit="True" Inherits="DotNetNuke.UI.Skins.Skin" EnableViewState="false" %>

<div id="ContentPane" runat="server">

As you can see, its quite basic. Its referencing DotNetNuke.UI.Skins.Skin and I think that may be the problem but when I remove that I get a 500 - Internal server error. Yet when I include it, I get the gobbledy-gook. 

What shall I do? If that snippet of code needs to be replaced, what should I replace it with to get just the actual xml code to display?

New Around Here
Posts: 8
New Around Here
New Poster
New Poster
Congrats on posting!

Hello Moderator, it looks like the code I included in my original post got mangled. How do I add code snippets to a post? Also can you please delete this post and I will repost it in such a way where the code can be clearly seen and understood.

Veteran Member
Posts: 838
Veteran Member
3 Helpful Replier
Helpful Replier
Thanks for being such a helpful replier!
New Poster
New Poster
Congrats on posting!

What shall you do?

What about https://github.com/DNNCom...N.NewsFeeds/releases ?

New Around Here
Posts: 8
New Around Here
New Poster
New Poster
Congrats on posting!

Sorry, it looks like my code was mangled on the initial post. Here is the code that is partially working. 

I really try to avoid 3rd party mods. The Razor Host module is so versatile, outside mods aren't as needed. 

Is there no way to do this with the core tools?

Skin code:

Advanced Member
Posts: 233
Advanced Member
4 Helpful Replier
Helpful Replier
Thanks for being such a helpful replier!
New Poster
New Poster
Congrats on posting!
4 Engaged Reader
Engaged Reader
You are an engaged reader!

Posted By Faith Coder on 1/29/2026 1:41 PM

Hello Moderator, it looks like the code I included in my original post got mangled. How do I add code snippets to a post? Also can you please delete this post and I will repost it in such a way where the code can be clearly seen and understood.



We have fixed this in the forums module (https://github.com/DNNCom...nityForums/pull/1566 )
but it has not yet been installed here
Senior Member
Posts: 1322
Senior Member
3 Helpful Replier
Helpful Replier
Thanks for being such a helpful replier!
Lifesaver
Lifesaver
You're Life Saver!
New Poster
New Poster
Congrats on posting!
3 Engaged Reader
Engaged Reader
You are an engaged reader!
BTH, I don't think you can create an RSS feed this way as DNN will still render the complete page even if the Skin is pretty much empty.
I know Open Content has an option for this, you can find the code here, maybe it will help you.

https://github.com/sachat...ntent/Components/Rss

This template uses this:
https://github.com/sachat...ter/Articles/rss.hbs


Senior Member
Posts: 1322
Senior Member
3 Helpful Replier
Helpful Replier
Thanks for being such a helpful replier!
Lifesaver
Lifesaver
You're Life Saver!
New Poster
New Poster
Congrats on posting!
3 Engaged Reader
Engaged Reader
You are an engaged reader!

BTW, you said you prefer no other modules, but I use the Open Content in some case like you use the Razor Host module, as a "template" can also be a single razor file. (with @dnn helpers included). But "on steroids" as you can easily add custom settings for instance.

An example: https://github.com/40fing...03.10-Razor-DNN-Menu

Advanced Member
Posts: 132
Advanced Member
Helpful Replier
Helpful Replier
Thanks for being such a helpful replier!
MVP
MVP
You're an MVP!
2 Engaged Reader
Engaged Reader
You are an engaged reader!
Avid Reader
Avid Reader
Avid Reader art thou!
Unfortunately as others have mentioned I do not believe you will be able to acheive what you are looking for with a MVC module due to the fact that MVC Module is really rendering inline with the DNN Main Webform Module so you will have other content contained within. You would need to use a APIController, or other mechanism such as an .aspx page to bypass the entire pipeline that adds the theme etc.
New Around Here
Posts: 8
New Around Here
New Poster
New Poster
Congrats on posting!
  • Accepted Answer

Thanks everyone for your feedback. 

The code below is working. Basically I'm using razor to create an XML file on the server and populate it using file IO operations. No third-party mods have been installed. This is just using the core tools.

Does anyone see any problems with doing it this way as I know that just because something works doesn't necessarily mean it should be done :-)

 

 

Advanced Member
Posts: 132
Advanced Member
Helpful Replier
Helpful Replier
Thanks for being such a helpful replier!
MVP
MVP
You're an MVP!
2 Engaged Reader
Engaged Reader
You are an engaged reader!
Avid Reader
Avid Reader
Avid Reader art thou!
If this is just a module on a page, and writing to a file it would be pretty easy to overwhelm the system and cause errors with simultaneious locks and the like, so I would just ensure that the "Creation of the file" isn't something the public can hit.
Page 1 of 212 > >>

These Forums are for the discussion of the open source CMS DNN platform and ecosystem.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
  2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
  3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  5. No Flaming or Trolling.
  6. No Profanity, Racism, or Prejudice.
  7. Site Moderators have the final word on approving / removing a thread or post or comment.
  8. English language posting only, please.

Would you like to help us?

Awesome! Simply post in the forums using the link below and we'll get you started.

Get Involved