1
votes

I'm working on project RSS generation in MVC.Net. in taht i want to make bookmark. for that i have write the code on controller. first there is one aspx page from which subscription page gets open.

public ActionResult ViewBlog() { if (Session[SessionVariables.username] == null) { return RedirectToAction("Login", "Home"); } else { return View(classObj.fetchAllBlogs()); } }

and coding for subscription is: public ActionResult Rss() {

           string bcontent = classObj.showBlog();
           DateTime postdate = classObj.showPostDate();

           List<SyndicationItem> items = new SyndicationItem[] 
        {
            new SyndicationItem("RSS Blog",bcontent+postdate,null),       
        }.ToList();

           RssResult r = new RssResult();
           SyndicationFeed feed = new SyndicationFeed("Admin: Blog Posts", "RSS Feed",Request.Url , items);
           return new RssResult(feed);

        Developer", "The latest news on ASP.NET, C# and ASP.NET MVC ");
    }

but problem is that when usr clicks on bookmark then intested of opening ViewBlog.aspx it opens the same page. i want to open ViewBlog.aspx. I think the problem is in: SyndicationFeed feed = new SyndicationFeed("Admin: Blog Posts", "RSS Feed",Request.Url , items);

Plz help ...!

1
Can you double check your code example. The last line looks like it shouldn't be there. Or you've made a syntax error.Richard Garside

1 Answers

0
votes

The 3rd parameter of the SyndicationFeed constructor should be the URL of the RSS feed. If this doesn't change then I would just hard code it.

Like they've done in the example in the MS docs.

SyndicationFeed feed = new SyndicationFeed("My Data Feed", "This is a sample feed", new Uri("http://localhost/MyDataService"), items);