November Happy Hour will be moved to Thursday December 5th.

Intellisense problem razor episerver 7

Vote:
 

I'm learning EpiServer 7 built on MVC and am now trying to make the PropertyFor work as I want it. I have a property called title and if I write it like this (code below), it renders correctly but I dont't get any intellisense for the Linq expression inside (the x). You see what namespaces I am using and I have also added System.Linq in the webconfig for views. What do I need to do to get intellisense?

 

@using System
@using System.Data
@using EPiServer.Cms
@using EPiServer.Core
@using EPiServer.Web.Mvc.Html

@model MyApplication.Models.Pages.StartPage

<h2 class="@Html.EditAttributes(x => x.Title)">
    @Html.PropertyFor(x => x.Title)
</h2>
    

Note. The alloy MVC demo site have this problem for me as well so can't find any good solution there. I can't add System.Linq in the razor page, the page can't find the reference.

Thanks!

 

#72883
Jul 02, 2013 11:58
Vote:
 

Do you have ReSharper installed?

#72906
Jul 02, 2013 16:25
Vote:
 

I don't have ReSharper installed, if it's possible to solve it without having to buy a product it would be great since I don't use my private computer for business.

How come I need ReSharper? Html.EditorFor(), Html.TextBoxFor() and so onworks with intellisense and I have never had and issues with razor intellisense when programming...?

#72910
Jul 02, 2013 17:01
Vote:
 

not sure if this apply to mvctemplates but make sure you have tagprefix for episerver as well as standard .net in web.config. if you do not have those it might not work. same goes for standard .net.

#72911
Jul 02, 2013 20:46
Vote:
 

Hmm, After testing a little I realize that not even Html.TextBoxFor(linq-epression) has intellisensse as well as basix ViewBag.DynamicEpression. It feels like this might not be an epi-issue but more of an issue when I merged the epiinstallation and an empty mvc 4 project.

#72912
Jul 02, 2013 21:52
Vote:
 

I think it had to do with the merging of the two projects. I changed the project's target frameowrk from 4.0 to 4.5 and it now works like a charm :)

#72913
Jul 02, 2013 22:05
Vote:
 

moste of the time when you do not have intellisens visual studio complain about the web.config. There is a section in web.config that tell vs the libraries you should have intellisense for. you could also add your own code to that section. it is almost like when you add user controls in top of your webforms document in webforms applications. Have a look at an empty web.config from that comes with the empty episerver vs integrations installation.

#72914
Jul 02, 2013 22:06
Vote:
 

it should not matter if you change the target framework since episerver standard is .net 4.0. I google a bit and Microsoft confirmed a bug as well for MVC 4 http://connect.microsoft.com/VisualStudio/feedback/details/727729/viewbag-not-recognized-in-asp-net-mvc-4-project. A restart might help as well. The section in web.config should look something like this for ordinary MVC support

   <pages>
      <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="System.Web.WebPages"/>
        <add namespace="System.Web.Helpers" />
      </namespaces>
    </pages>

    

#72915
Edited, Jul 02, 2013 22:09
Vote:
 

I couldn't remember where I found this solution, but it worked for me. You need to add targetFramework=4.0 in you web.config under compliation section

<compilation defaultLanguage="c#" optimizeCompilations="true" debug="true" targetFramework="4.0">
....
..

    

 

#73000
Jul 03, 2013 16:57
Vote:
 

What I learned from this, target framework in project and in webconfig must be the same. Apperantly they were not when merging the two projects. Thank you all for your help!

#73060
Jul 04, 2013 20:52
Vote:
 

I can concurr to Andreas last statement.  Helped me anyway :)

#80667
Jan 29, 2014 9:25
Vote:
 

I had to add the following keys to appsettings in web.config to get the intellisense up and running

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

    

 

 

#80890
Feb 04, 2014 13:56
Vote:
 

Intellisense is working for me with these two changes

targetFramework=4.0

and 

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

 

#85847
May 07, 2014 9:50
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.