3

I am having an issue with my strongly typed view. I try everything possible and did read alot about the web.config related . I coudn't find the issue. below is from the view.

@model IEnumerable<RoomsForRent.Domain.Entities.Room>

@{
    ViewBag.Title = "Home";
}

My Domain entity RoomsForRent.Domain.Entities.Room shows unknown element. The ViewBag, @model is showing does not exist. From the web.Config of my view .

<configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    </sectionGroup>
  </configSections>

  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>

  <appSettings>
    <add key="webpages:Enabled" value="false" />
  </appSettings>

Please is there anything i am missing ? I recently deleted and restart the project from beginning , yet the same error is showing. I am confused.

Nuru Salihu
  • 4,756
  • 17
  • 65
  • 116

2 Answers2

4

Had same problem. Information inside of project were outdated in reference to dll files. Made these changes.

1) Inside main web.config

<appSettings>
    <add key="webpages:Version" **value="1.0.0.0"**/> --> value="2.0.0.0"
</appSettings>

2) Inside View web.config changed all Version values to current MVC version

<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, ....
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, ....
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, ...>
  <controls>
<add assembly="System.Web.Mvc, Version=4.0.0.0.,... />

Also, in order for project to get changes had to restart it. After restarting all was working fine.

Hope it helps.

chassis
  • 84
  • 3
  • Thanks for the suggetsion , but i replace the version already. I installed new version 2012 and didn't have the prob after all. Although i didn't try but i think u do have a good point. – Nuru Salihu Feb 11 '15 at 19:05
0

I would first check if there is a Web.config file in ./Views/Web.config

Eskinder
  • 1,369
  • 1
  • 14
  • 24