2
votes

Refer to
Good and full implementation of RSS feeds in ASP.net MVC

Check the answer of Trevor de Koekkoek.

I am getting this error CS1061: 'object' does not contain a definition for 'Items' and no extension method 'Items' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

3

3 Answers

4
votes

I had this problem. My fix was to search and replace all instances of "System.Web.Mvc, Version=2.0.0.0" with "System.Web.Mvc, Version=3.0.0.0"

There are multiple web.config files.

0
votes

You may get this error if you have an MVC 2 project that at one point was an MVC 3 project.

This happened to me when I had to revert back to an MVC 2 version of an MVC 3 project. I had shelved my MVC 3.0 changes and brached the code in TFS (to make hotfixes to the MVC 2 version), but had leftover web.config files for my Razor Views. This was confusing the compiler.

  • Search for web.config in your directory structure (in Windows explorer or Visual Studio's 'find in files'). Don't do 'Search in Solution' because you may have web.config files not present in the project. IIS will still load them even if they're not in your solution. Rename any web.config files containing 3.0.0.0 to _web.config and it will stop looking. Then restart IIS.

This should fix the problem.

If you still have the problem you may need to close all Visual Studio instances, stop IIS and delete temporary internet files. You can get the path to this directory by clicking the 'Show Detailed Compiler Output' link on the error page and searching for 'temporary'.

-1
votes

Do you get that error in the view ? In that case, you need to make your view strongly typed with SyndicationFeed as your model.

This means you should declare your View (.aspx) as something along the lines of:

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<System.ServiceModel.Syndication.SyndicationFeed>" %>

This tells the view that the type of ViewData.Model is SyndicationFeed, so that you can access its properties and methods without casting.