Hello all I am trying to create a live updated RSS feed for itunes using asp.net MVC. I can't seem to get the feed to validate and when you navigate to the page the xml is not formatted like it is when I made one with a webforms.
This is the View
@model IEnumerable<lofbc.org.Models.media>
@{
Layout = null;
}
<?xml version="1.0" encoding="UTF-8" ?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:itunesu="http://www.itunesu.com/feed" version="2.0">
<channel>
<title>Life of Faith Bible Church Podcast</title>
<link>@Request.Url.Host</link>
<description>Welcome to Life of Faith Bible Church! We are dedicated to bringing you life-changing resources through our podcast and audio messages. You will find a wealth of material that will help you triumph in every area of life.</description>
<language>en-us</language>
<copyright>New Life Media copyright @DateTime.Now.Year</copyright>
<atom:link href="https://www.lofbc.org/rss" rel="self" type="application/rss+xml" />
<!--itunes specific-->
<itunes:author>Life of Faith Bible Church</itunes:author>
<itunes:summary>Welcome to Life of Faith Bible Church! We are dedicated to bringing you life-changing resources through our podcast and audio messages. You will find a wealth of material that will help you triumph in every area of life.</itunes:summary>
<itunes:owner>
<itunes:name>Life of Faith Bible Church</itunes:name>
<itunes:email>justin@lofbc.org</itunes:email>
</itunes:owner>
<itunes:explicit>No</itunes:explicit>
<itunes:image href="http://www.lofbc.org/rss/artwork/artwork.jpg" />
<itunes:category text="Religion & Spirituality"> </itunes:category>
@foreach (var item in Model)
{
var date = item.createdDate.ToString("yyyy");
var path = item.audioPath.ToString().Replace(".f4v", ".mp3");
<item>
<title>@item.title</title>
<url>http://lofbc-media.s3.amazonaws.com/@date/Audio/mp3/@path</url>
<pubDate>@item.createdDate.ToString("MMM dd, yyyy")</pubDate>
<description>@item.description</description>
<enclosure url="http://lofbc-media.s3.amazonaws.com/@item.createdDate.ToString("yyyy"))/Audio/mp3/@item.audioPath.ToString().Replace(".f4v", ".mp3")" length="" type="audio/mpeg" />
<itunes:summary>@item.description</itunes:summary>
</item>
}
</channel>
</rss>
and this is the controller
using lofbc.org.context;
using lofbc.org.Models;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace lofbc.org.Controllers
{
public class rssController : Controller
{
// GET: rss
public ActionResult Index()
{
using (ServiceArchivesEntities db = new ServiceArchivesEntities())
{
try
{
DateTime startDate = DateTime.Parse("01/01/2015 00:00:00");
var MT = (from a in db.tbl_media
join b in db.tbl_media_ministers
on a.MinisterID equals b.ID
select new media
{
id = a.ID,
createdDate = (DateTime)a.CreatedDate,
title = a.Title,
minister = b.Title + " " + b.FirstName + " " + b.LastName,
audioPath = a.PathToAudio,
videoPath = a.PathToVideo,
views = a.Views,
listens = a.Listens,
status = a.Status
}).Where(t => t.status == 2 && t.createdDate >= startDate).OrderByDescending(t => t.createdDate).Take(100).ToList();
return View(MT);
}
catch (SqlException ex)
{
Response.Write(ex.ToString());
return View();
}
}
}
}
}
Live demo http://development.lofbc.org/rss