I'm loving the new models builder to work with razor, however I'm having 1 issue. Html.RenderPartial doesn't seem to exist with modelbuilder I'm getting errors such as :
Error 73 'System.Web.Mvc.HtmlHelper<Umbraco.Web.Models.RenderModel<Umbraco.Web.PublishedContentModels.LandingPage>>' does not contain a definition for 'RenderPartial' and no extension method 'RenderPartial' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<Umbraco.Web.Models.RenderModel<Umbraco.Web.PublishedContentModels.LandingPage>>' could be found (are you missing a using directive or an assembly reference?)
Error 8 'System.Web.Mvc.HtmlHelper<Umbraco.Web.Models.RenderModel<Umbraco.Web.PublishedContentModels.BranchLocationPage>>' does not contain a definition for 'RenderPartial' and no extension method 'RenderPartial' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<Umbraco.Web.Models.RenderModel<Umbraco.Web.PublishedContentModels.BranchLocationPage>>' could be found (are you missing a using directive or an assembly reference?)
Error 9 'System.Web.Mvc.HtmlHelper<Umbraco.Web.Models.RenderModel<Umbraco.Web.PublishedContentModels.BranchLocationPage>>' does not contain a definition for 'RenderPartial' and no extension method 'RenderPartial' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<Umbraco.Web.Models.RenderModel<Umbraco.Web.PublishedContentModels.BranchLocationPage>>' could be found (are you missing a using directive or an assembly reference?)
Error 10 'System.Web.Mvc.HtmlHelper<Umbraco.Web.Models.RenderModel<Umbraco.Web.PublishedContentModels.BranchLocationPage>>' does not contain a definition for 'RenderPartial' and no extension method 'RenderPartial' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<Umbraco.Web.Models.RenderModel<Umbraco.Web.PublishedContentModels.BranchLocationPage>>' could be found (are you missing a using directive or an assembly reference?)
Keep in mind I forgot to mention this in the first post.
The page still renders fine. I simply get these errors in Visual Studio.
:) Yes, it should be a default, something must have gone missing during your installation. So if you dont want to add this using statement in every view, do this:
Check your views Web.config (NOTE: the web.config in your Views folder, not the root web.config.). This file holds the defaults for every view in your solution. Check the element system.web.webPages.razor and namespaces, does it have a reference to System.Web.Mvc? It should, otherwise add it. Here are the namespaces from a clean install:
Hahaha, we posted the same thing at the same time.
As my edit says, it's already there, which is why I find this odd.
EDIT: Actually... this brings up another question I have. I recently came back to Umbraco after a small hiatus (pre 7.2.4). I'm noticing that your version of MVC is 5 and not 4. Is the standard no longer to start a MVC 4 project and install umbraco through nuget?
I think (I cannot confirm as my experience with 7.4 and Model builder is limited so far), that it is the dynamic creation of the models that causes that "error" in visual studio.
I found that if I change my Model Builder configuration (I can't remember the exact details I'm afraid) so that when I build it built a DLL rather than the run time models that I believe are turned on by default, it made the errors go away.
I think this is why it all works when it's running but not in Visual Studio.
Yes, Umbraco now runs on MVC5, so if you installed it on top of a MVC4 application, i can guess it would be a problem. Try to just change your views web.config to reference MVC5 instead.
However, since it's not breaking the site, only giving me errors in VS that I can ignore, I'm gonna put this in the learning experience bug and move on.
When installing Umbraco, i usally just create a Empty ASP.NET Web Application, and then install Umbraco with nuget. Umbraco ships with everything it needs in terms om MVC and what not.
Html.RenderPartial errors
I'm using Umbraco 7.4 with ModelsBuilder.
I'm working within visual studio.
I'm loving the new models builder to work with razor, however I'm having 1 issue. Html.RenderPartial doesn't seem to exist with modelbuilder I'm getting errors such as :
Any ideas?
Hi Greg.
Adding
@using System.Web.Mvc.Html
at the top of your view should solve this.Here's a view which gets these errors:
Keep in mind I forgot to mention this in the first post. The page still renders fine. I simply get these errors in Visual Studio.
Did you try adding @using System.Web.Mvc.Html?
... well that's embarrasing.
However, shouldn't that be a default? I can't recall any other MVC project where I had to specify this in every view.
EDIT: To clarify, I looked into the web.config in the views folder and this was intended present:
:) Yes, it should be a default, something must have gone missing during your installation. So if you dont want to add this using statement in every view, do this:
Check your views Web.config (NOTE: the web.config in your Views folder, not the root web.config.). This file holds the defaults for every view in your solution. Check the element system.web.webPages.razor and namespaces, does it have a reference to System.Web.Mvc? It should, otherwise add it. Here are the namespaces from a clean install:
With this configuration, you dont have to add the using statement in every view.
Let me know if it works out for you!!
Best of luck!!
Hahaha, we posted the same thing at the same time.
As my edit says, it's already there, which is why I find this odd.
EDIT: Actually... this brings up another question I have. I recently came back to Umbraco after a small hiatus (pre 7.2.4). I'm noticing that your version of MVC is 5 and not 4. Is the standard no longer to start a MVC 4 project and install umbraco through nuget?
Hi Greg,
I think (I cannot confirm as my experience with 7.4 and Model builder is limited so far), that it is the dynamic creation of the models that causes that "error" in visual studio.
I found that if I change my Model Builder configuration (I can't remember the exact details I'm afraid) so that when I build it built a DLL rather than the run time models that I believe are turned on by default, it made the errors go away.
I think this is why it all works when it's running but not in Visual Studio.
Hi Nik,
I'm actually already in DLL mode. I found this was the best way to work with it in Visual Studio.
I'm starting to think this is might be a MVC4 <-> MVC5, perhaps I installed Umbraco incorrectly from the start and I'm getting unexpected errors.
Yes, Umbraco now runs on MVC5, so if you installed it on top of a MVC4 application, i can guess it would be a problem. Try to just change your views web.config to reference MVC5 instead.
Switching to 5.2.3 in the web.config.
However, since it's not breaking the site, only giving me errors in VS that I can ignore, I'm gonna put this in the learning experience bug and move on.
Thanks for the help.
When installing Umbraco, i usally just create a Empty ASP.NET Web Application, and then install Umbraco with nuget. Umbraco ships with everything it needs in terms om MVC and what not.
Best of luck!
Sounds like a great idea Greg!
Good luck with the rest of your site!! :)
Have a great day!!!
is working on a reply...