This project is read-only.

How to Add a module with c# code in a page.

Topics: Troubleshooting, Writing modules
Oct 3, 2013 at 10:46 AM
Edited Oct 4, 2013 at 7:37 AM
I want to make a custom UI and add some c# code in a page (say Home Page).
How can i do so in Orchard CMS?

I have tried making a module "News".
I want to add google news feed in this module
so i write some C# code in a controller to get it.
 public List<News> GetNews()
            const string url = "";
            var reader = XmlReader.Create(url);
            var feed = SyndicationFeed.Load(reader);
            _newsList = new List<News>();
            foreach (var item in feed.Items)
                _newsList.Add(new News
                    Heading = item.Title.Text,
                    Summary = item.Summary.Text
            return _newsList;
 public class News
        public string Heading { get; set; }
        public string Summary { get; set; }
Now i am with a C# collection bind to a Div in .cshtml page.
<div id="newsFeed"></div>
I want this Div to be on my home page or on any other page where i need to display news.
as a reusable component
Oct 4, 2013 at 3:36 AM
This is so extremely vague it's impossible to give a meaningful answer beyond something like: "with Visual Studio", sorry. Please find a specific question to ask, explain what you tried, how it did not work, etc.
Oct 7, 2013 at 6:27 AM
Sorry for the lesser information.
I think now the edit version is with all information.
Oct 7, 2013 at 7:24 AM
It seems like you should read a few ASP.NET MVC tutorials. What you need to do is build a controller action and return a view from there with your news list as the model. Then, from your view, enumerate your model and render each news item as needed. Like you would in a regular MVC application.