" and "" in Asp.net MVC views Instead of recording <@ Import Namespace="Microsoft.SharePoint" %>...">

Globally, add "<@Assembly>" and "<namespace @Import>" in Asp.net MVC views

Instead of recording

<@ Import Namespace="Microsoft.SharePoint" %>

in every view that I create, I know that I can just edit my file web.configand add this:

...
<pages>
    <namespaces>
        <add namespace="Microsoft.SharePoint" />
    </namespaces>
</pages>

But this does not work during development. Visual Studio 2010 cannot see SPContextunless I add these two lines on top of my view:

<%@ Assembly Name="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint" %>

So, how do I add assemblies around the world and also import namespaces so that VS can resolve classes / objects?

+5
source share
2 answers

<assemblies> <compilation> <system.web>:

<compilation debug="false" targetFramework="4.0">
  <assemblies>
    <add 
      assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
  </assemblies>
</compilation>

targetFramework debug , , .

+5

, Web.config .

+2

All Articles