Razor intellisense not working in VS 2015

I have tried several times ever since VS 2015 officially release. I am having issue with ServiceStack Razor view’s intellisense. It’s not working.

Is this a known issue? Project itself works fine but razor view’s intellisense.

Here are some notes about Razor intelli-sense which may help: https://github.com/ServiceStack/ServiceStack/wiki/Razor-Notes

Essentially VS.NET uses the intelli-sense defined in your Web.config.

Tried several options without luck. Here is the what I have done.

Under VS 2015 create ServiceStack.Razor project.
Remove ServiceStack.Razor nuget package
Install WebPages nuget version to 3.2.3
Install ServiceStack.Razor

With above approach, it can use latest razor 3.2.3 without error on razor assembly. But intellisense still not working. From your article there is one of section saying change version number to 3.0.0.0. Do you have any example of project that has intellisense working properly under vs2015? If so I would like to check out the difference.

Thanks for help out.

I have also attached example project’s web.config below.

  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor" requirePermission="false" />
    </sectionGroup>
  </configSections>

  <system.web>
    <compilation targetFramework="4.5" debug="true">

      <buildProviders>
        <add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor" />
      </buildProviders>
    </compilation>
    <httpRuntime targetFramework="4.5" />
    <httpHandlers>
      <add path="*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" />
    </httpHandlers>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <urlCompression doStaticCompression="true" doDynamicCompression="false" />
    <handlers>
      <add path="*" name="ServiceStack.Factory" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
    </handlers>
  </system.webServer>

  <system.web.webPages.razor>
    <pages pageBaseType="ServiceStack.Razor.ViewPage">
      <namespaces>
        <add namespace="ServerManager.ServiceModel" />
        <add namespace="System" />
        <add namespace="ServiceStack" />
        <add namespace="ServiceStack.Html" />
        <add namespace="ServiceStack.Razor" />
        <add namespace="ServiceStack.Text" />
        <add namespace="ServiceStack.OrmLite" />
        <add namespace="ServerManager" />
      </namespaces>
    </pages>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc" />
  </system.web.webPages.razor>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <appSettings>
    <add key="webPages:Enabled" value="false" />
  </appSettings>
</configuration>

All the Live Demos that use Razor pages should have intelli-sense working e.g. Email Contacts

Email contacts project’s razor view doesn’t work under my VS 2015. I have uninstalled resharper, web essentials also I did VS reset yesterday.

NVM. I got it working

I have created a Asp.net 4.5.2 project and compared both and made several changes. As your razor notes state, it is relate to 3.0.0.0 version. But it have to add to several places.

Below is working version’s web.config. Thanks for all the help.

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    </sectionGroup>
  </configSections>

  <system.web>
    <compilation targetFramework="4.5" debug="true">

      <buildProviders>
        <add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor" />
      </buildProviders>
    </compilation>
    <httpRuntime targetFramework="4.5" />
    <httpHandlers>
      <add path="*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" />
    </httpHandlers>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <urlCompression doStaticCompression="true" doDynamicCompression="false" />
    <handlers>
      <add path="*" name="ServiceStack.Factory" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
    </handlers>
  </system.webServer>

  <system.web.webPages.razor>
    <pages pageBaseType="ServiceStack.Razor.ViewPage">
      <namespaces>
        <add namespace="ServerManager.ServiceModel" />
        <add namespace="System" />
        <add namespace="ServiceStack" />
        <add namespace="ServiceStack.Html" />
        <add namespace="ServiceStack.Razor" />
        <add namespace="ServiceStack.Text" />
        <add namespace="ServiceStack.OrmLite" />
        <add namespace="ServerManager" />
      </namespaces>
    </pages>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  </system.web.webPages.razor>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <appSettings>
    <add key="webPages:Enabled" value="false" />
  </appSettings>
</configuration>
2 Likes

I spent a few hours with the same problem. I cloned the emailcontacts repo and saw that intellisense was not working. When I copied the webconfig posted above it worked. One thing that tripped me up was that I also had to set the publickeytoken on this line:

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />