I have upgraded from Umbraco 4.11 to 6.1.6 and aparently some of the methods or namespaces have changed and caused a few of my Razor scripts to break. Here is one very basic example, could someone point me in the right direction to fixing the issue? I am sure it is something simple. Thanks!
I found another error with a Contour script as well here is the error:
\\umbracoshare\prep\wwwroot_6x\umbraco\plugins\umbracoContour\Views\Form.cshtml(28): error CS0619: 'System.Web.Mvc.HtmlHelper.AntiForgeryToken(string)' is obsolete: 'This method is deprecated. Use the AntiForgeryToken() method instead. To specify custom data to be embedded within the token, use the static AntiForgeryConfig.AdditionalDataProvider property.'
I was thinking since you have to do some rewite of your Razor, when you are going from Umbraco version 4 to Umbraco 6, then you should consider, to use dynaic razor or stronly typed razor instead of the DynamicNode Razor. Dynamic node Razor is a old legacy Razor and will be deprecated.
And you have to make some chantes to the webconfig file to run MVC. The only thing you need is to enable this in ~/config/umbracoSettings.config by setting the defaultRenderingEngine setting to MVC as such
The last thing I would mentionis the way you use the the Umbraco library methods, In MVC you call it by using @Umbraco. so if you need to get node by id. In MVC you do it like this: Umbraco.Content(1234);
By changingfrom the DynamicNode Razor, to MVC you will get a faster site at the end, and if you upgrade to version 7 later on, then you don´t have to do the conversionagain.
Just my thoughtswhenyou are rewriting your Razor from Umbraco version 4 to version 6 why not go the whole way.
One thing I would add is that while it is recommend that you switch to MVC you can continue to use WebForms with the new Razor by converting Razor Macros to Partial View Macros.
I am a one man show for a medium sized private college, so I am doing as much as I can handle right now. I've thought about Mvc, but quite frankly, don't see much advantage with our site. I know that alot of people are switching to Mvc, but at this time it would require too much time to learn.
The error occurs if you upgrade Umbraco without upgrading Contour to the latest version. There is however an error in the documentation that will cause another issue. There is an xsltExtensions.config file which allows you to register 3rd party xslt extensions.
The Contour documentation says to add this line to the file:
Razor Scripts Broken from Upgrade v4 to v6
I have upgraded from Umbraco 4.11 to 6.1.6 and aparently some of the methods or namespaces have changed and caused a few of my Razor scripts to break. Here is one very basic example, could someone point me in the right direction to fixing the issue? I am sure it is something simple. Thanks!
I think Jeavon's post is apt here? http://our.umbraco.org/forum/developers/razor/49926-macro-scripts-work-in-4x-but-not-in-616
Hi Steve,
What about this:
Maybe to check if your fields is empty you could use the HasValue.
Hope this helps,
/Dennis
Also your errors will be sent to \App_Data\Logs\UmbracoTraceLog.txt that should help you weed them out more quickly!
@Steve Morgan is bang on, check the link he posted
Thanks everyone, that seemed to fix it. Is there anything else I should be aware of?
I found another error with a Contour script as well here is the error:
\\umbracoshare\prep\wwwroot_6x\umbraco\plugins\umbracoContour\Views\Form.cshtml(28): error CS0619: 'System.Web.Mvc.HtmlHelper.AntiForgeryToken(string)' is obsolete: 'This method is deprecated. Use the AntiForgeryToken() method instead. To specify custom data to be embedded within the token, use the static AntiForgeryConfig.AdditionalDataProvider property.'
Should I post this to the Contour forum?
Hi Steve,
I was thinking since you have to do some rewite of your Razor, when you are going from Umbraco version 4 to Umbraco 6, then you should consider, to use dynaic razor or stronly typed razor instead of the DynamicNode Razor. Dynamic node Razor is a old legacy Razor and will be deprecated.
And the rewriting from DynamicNode Razor to Dynamic Razor or Strongly Typed Razor isn´t so hard. There are not so big difference. E.g instead of @Model you´re using the @CurrentPage. You can see the differencehere: http://our.umbraco.org/documentation/reference/templating/macros/Partial-View-Macros/
But this requires that you also change from using Webforms to using MVC. Here is a cheetsheet on how to convert masterpages to views. http://our.umbraco.org/documentation/cheatsheets/masterpages2views.pdf
And you have to make some chantes to the webconfig file to run MVC. The only thing you need is to enable this in ~/config/umbracoSettings.config by setting the defaultRenderingEngine setting to MVC as such
The last thing I would mention is the way you use the the Umbraco library methods, In MVC you call it by using @Umbraco. so if you need to get node by id. In MVC you do it like this: Umbraco.Content(1234);
By changing from the DynamicNode Razor, to MVC you will get a faster site at the end, and if you upgrade to version 7 later on, then you don´t have to do the conversion again.
Just my thoughts when you are rewriting your Razor from Umbraco version 4 to version 6 why not go the whole way.
/Dennis
Great thoughts @Dennis
One thing I would add is that while it is recommend that you switch to MVC you can continue to use WebForms with the new Razor by converting Razor Macros to Partial View Macros.
Dennis,
I am a one man show for a medium sized private college, so I am doing as much as I can handle right now. I've thought about Mvc, but quite frankly, don't see much advantage with our site. I know that alot of people are switching to Mvc, but at this time it would require too much time to learn.
The error occurs if you upgrade Umbraco without upgrading Contour to the latest version. There is however an error in the documentation that will cause another issue. There is an xsltExtensions.config file which allows you to register 3rd party xslt extensions.
The Contour documentation says to add this line to the file:
<ext assembly="/bin/Umbraco.Forms.Core" type="Umbraco.Forms.Library" alias="umbraco.contour" >
But it should be:
<ext assembly="Umbraco.Forms.Core" type="Umbraco.Forms.Library" alias="umbraco.contour" />
is working on a reply...