Hopefully someone can give me a hand. I am trying to move away from webforms in umbraco 7 into MVC but I'm off to a bad start.
I'll explain step by step what I have done and hopefully someone can correct me if I made any mistakes...
Downloaded the latest version of umbraco 7
Copied all the files to a folder
Opened VS2013
File/open/Web Site
Ran the code and completed all the configuration steps and everything is running fine (installed a sample template to get my head around the MVC), however...
Pulled up the Home.cshtml from the Views folder in VS2013
The way you are using visual studio is probably your problem.
You copied the files to a folder than used File -> Open -> Website. As such your web.config in the views folder could be wrong, or because it's not a web project type it might not trigger intellisense.
The preferred pattern goes something like this (in my opinion)..
Open Visual Studio
File -> New -> Project
Chose the Web Tab and ASP.Net Web Application
Give the project a name
Give the project a Location
Give the solution a name (if you want it to be different than the project name)
Click OK
You should now be prompted with the New ASP.Net Project Wizard.
Chose Empty and do not check Web Forms, MVC, or Web Api, or Add Unit Tests, Leave it all empty.
Click OK
Once the Project is Open, Open the Nuget Package Console
VS2013 Intellisense not working on views
Hi everyone,
Hopefully someone can give me a hand. I am trying to move away from webforms in umbraco 7 into MVC but I'm off to a bad start.
I'll explain step by step what I have done and hopefully someone can correct me if I made any mistakes...
Ran the code and completed all the configuration steps and everything is running fine (installed a sample template to get my head around the MVC), however...
Pulled up the Home.cshtml from the Views folder in VS2013
When I type @CurrentPage and press the '.' nothing comes up.
I've tried to delete the .suo, reset the settings in VS, restarting...nothing.
Your help will be mostly appreciated.
Best regards, Pedro
Hi Pedro,
You need to use IPublishedContent to get intellisense in VS.
We normally change our views to inherit from:
You can then use:
Cheers,
Marc
HI Pedro - is the view file included in the project?
If you created it in the Umbraco UI then you may have to manually refresh the file list and include it.
The way you are using visual studio is probably your problem.
You copied the files to a folder than used File -> Open -> Website. As such your web.config in the views folder could be wrong, or because it's not a web project type it might not trigger intellisense.
The preferred pattern goes something like this (in my opinion)..
Click OK
Once the Project is Open, Open the Nuget Package Console
Tools -> Nuget Package Manager -> Package Manager Console
This should open in the tabs at the bottom of the IDE. Go to it and you should be at a Prompt with "PM> " prefixing the cursor.
Make sure the Package source: drop down is set to nuget.org
Type: "Install-Package UmbracoCms" at the prompt and press enter
And away it goes,
This will install Umbraco Into the project and all of it's dependencies, including MVC 4 and Newtonsoft.Json, etc etc.
-Note
As Pedro said @CurrentPage won't give you intellisense because it is a Dynamic Object, there is no intellisense on Dynamic Objects.
Change your view to inherit from
@inherits UmbracoTemplatePage
Then you can do @Model.Content.Name @Umbraco.TypedContent.. @Model.Content.ContentType.. etc etc etc and you'll get intellisense.
is working on a reply...