Vulnerability in EPiServer.Forms
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?
<h2 class="@Html.EditAttributes(x => x.Title)">
@Html.PropertyFor(x => x.Title)
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.
Do you have ReSharper installed?
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...?
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.
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.
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 :)
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.
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
<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.Helpers" />
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">
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!
I can concurr to Andreas last statement. Helped me anyway :)
I had to add the following keys to appsettings in web.config to get the intellisense up and running
<add key="webpages:Version" value="18.104.22.168" />
<add key="webpages:Enabled" value="false" />
Intellisense is working for me with these two changes
<add key="webpages:Version" value="22.214.171.124" /><add key="webpages:Enabled" value="false" />