MVC的Razor视图在VS 2013的智能感知破 [英] MVC Razor view Intellisense broken in VS 2013

查看:262
本文介绍了MVC的Razor视图在VS 2013的智能感知破的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写在VS2010的现有项目这在VS2010加载时完美的作品。

I have an existing project written in VS2010 which when loaded in VS2010 works perfectly.

当我在VS2013加载同一项目MVC剃刀视图包含大量的错误,如果配置文件是从意见文件夹中缺少。

When I load this same project in VS2013 the MVC Razor views contain lots of errors as if the config file is missing from the views folder.

这似乎并没有加载剃刀编辑器使用正确的从根和views文件夹两个配置文件,而是给了我这样的错误...

It appears to have not loaded the Razor editor correctly using the config files from both the root and the views folder and instead gives me errors like ...

The name 'model' does not exist in the current context

和...

'System.Web.WebPages.Html.HtmlHelper' does not contain a definition for 'LabelFor' 
and no extension method 'LabelFor' accepting a first argument of type 
'System.Web.WebPages.Html.HtmlHelper' could be found 
(are you missing a using directive or an assembly reference?)

...

任何想法什么会导致此?

Any idea what would cause this?

编辑:
配置文件的要求....

Config files as requested ....

从主web.config文件(不是全部,因为它是太大了张贴)
     
        
        
        
        
        
        
      
      
        
        
        
        
        
          
            
            
            
            
            
            
            
            
            
            
            
          
        
        
          
            
            
            
            
            
            
          
          
            
            
            
            
            
            
            
            
            
            
            
          
        
    

From main web.config file (not all of it as it's way too big to post)

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="Ninject" culture="neutral" publicKeyToken="c7192dc5380945e7" />
            <bindingRedirect newVersion="3.0.0.0" oldVersion="0.0.0.0-3.0.0.0" />
        </dependentAssembly>
        <dependentAssembly>
            <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Validation" culture="neutral" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect newVersion="5.0.505.0" oldVersion="0.0.0.0-5.0.505.0" />
        </dependentAssembly>
        <dependentAssembly>
            <assemblyIdentity name="System.Web" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
        </dependentAssembly>
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
        </dependentAssembly>
        <dependentAssembly>
            <assemblyIdentity name="Microsoft.Practices.ServiceLocation" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-1.2.0.0" newVersion="1.2.0.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>

在〜/查看/配置文件...

Config file in "~/Views/" ...

<?xml version="1.0"?>  
<configuration>
    <configSections>
        <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
            <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.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=3.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" />
                <add namespace="Emedia.Common.Mvc.Views.Helpers"/>
                <add namespace="Emedia.Common.Mvc.Views.Extensions"/>
        <add namespace="Emedia.Common.Utilities"/>
        <add namespace="Emedia.Common.Utilities.Extensions"/> 
        <add namespace="Emedia.Common.Mvc.Controllers.Helpers"/>
                <add namespace="Emedia.Resources.Service"/>
        <add namespace="Emedia.Subscriber.Controllers"/>
        <add namespace="Emedia.Subscriber.Controllers.ViewModels"/>
            </namespaces>
        </pages>
    </system.web.webPages.razor>

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

    <system.web>
        <httpHandlers>
            <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
        </httpHandlers>
        <pages
            validateRequest="false"
            pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
            pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
            userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <controls>
                <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
        </controls>
    </pages>
</system.web>

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />

    <handlers>
        <remove name="BlockViewHandler"/>
        <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
    </handlers>
</system.webServer>

推荐答案

我最终有一堆的,因为网络服务器崩溃的个人电脑上的其他问题,并最终重新安装Visual Studio中。

I eventually had a bunch of other problems on my pc because of a network server crash and ended up reinstalling visual studio.

这显然解决了这个问题...我不知道如何,但它没有。

This apparently solved the problem ... i have no idea how but it did.

我不知道,也许在我的情况下,它只是刚刚出现故障的安装而不是典型的问题。

I wonder if maybe in my case it was simply just a faulty installation rather than the typical problem.

由于这个原因,因为他们是潜在的好回答这个问题,我将标志着这是答案,但+1所有其他回复。

For that reason I will mark this as the answer but +1 all other replies as they are potentially good answers to this problem.

然而,我却发现,微软明确指出的Visual Studio 2013不支持智能感知较低版本的MVC比4,所以如果你使用的是如果你使用MVC的新版本并没有什么人在这里MVC 3升级项目工程试重新安装Visual Studio中。

I did however find that Microsoft clearly states visual studio 2013 does not support intellisense on lower versions of MVC than 4 so if you are using MVC 3 upgrade your project if you are using a newer version of MVC and nothing else here works try reinstalling visual studio.

另外值得一提...
MVC是现在的NuGet包,所以不要从下载安装REDIST MVC允许VS去弄清楚你。

Also worth noting ... MVC is now a nuget package so don't install MVC from the download redist allow VS to figure that out for you.

这篇关于MVC的Razor视图在VS 2013的智能感知破的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆