2010-04-28 54 views
1

我正在从事MVC.Net项目的RSS生成工作。在我想做书签。因为我已经在控制器上写了代码。首先有一个aspx页面从中打开订阅页面。Rss:书签无法正常工作

公众的ActionResult ViewBlog(){ 如果 (会话[SessionVariables.username] == NULL){ 回报 RedirectToAction( “登录”, “家”); } else { return View(classObj.fetchAllBlogs()); }}

和编码认购是: 公众的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 "); 
    } 

,但问题是,当USR点击书签,然后intested开放ViewBlog.aspx它打开同一个页面。我想打开ViewBlog.aspx。我认为问题在于: SyndicationFeed feed = new SyndicationFeed(“Admin:Blog Posts”,“RSS Feed”,Request.Url,items);

Plz help ...!

+0

你可以仔细检查你的代码示例。最后一行看起来不应该在那里。或者你犯了一个语法错误。 – 2010-04-28 08:57:08

回答

0

SyndicationFeed构造函数的第三个参数应该是RSS提要的URL。如果这不改变,那么我只是硬编码它。

就像他们在example in the MS docs中所做的一样。

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

嘿它的工作...非常感谢你..... – shruti 2010-04-28 09:46:42

+0

嘿,你可以告诉我如何在mvc.net中创建动态视图页 – shruti 2010-04-28 09:53:16