“@Model”, “@Viewbag” and “@Url” “does not exist in the current context” Razor MVC3 when using Visual Studio 11 Beta/Visual Studio 2012 RC

前端 未结 3 1648
故里飘歌
故里飘歌 2021-02-19 10:38

I\'ve created an MVC3 application in Visual Studio 10. When editing views the \"@Model\", \"@Viewbag\" and \"@Url\" all appear valid.

I recently installed Visual Studio

相关标签:
3条回答
  • 2021-02-19 11:13

    Add the following setting to your MAIN web.config file's appSettings section:

    <add key="webpages:Version" value="1.0.0.0"/>
    

    From Connect: http://connect.microsoft.com/VisualStudio/feedback/details/732597/visual-studio-11-beta-razor-intellisense-not-working

    0 讨论(0)
  • 2021-02-19 11:14

    For anyone that hits this page through searching, I was able to resolve this myself by following the guide on this page, line by line, until I could rebuild the project. Once I rebuilt and reloaded the project, all the intellisense came back for me.

    Here is the link: http://www.asp.net/mvc/overview/releases/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2

    0 讨论(0)
  • 2021-02-19 11:15

    An update for vs2015;

    Look for this element in your MAIN web.config

      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    

    and place the "newVersion" parameter in your webPages:version

    ie

    <add key="webpages:Version" value="3.0.0.0" />
    
    0 讨论(0)
提交回复
热议问题