I've had a similar issue and fixed it by changing Umbraco.Core.Components to Umbraco.Core.Composing.
Also, implementing the code in the documentation I figured that you also need to use Umbraco.Web.
I created a pull request for that, should I delete it (https://github.com/umbraco/UmbracoDocs/pull/1616)? Also, the docs still don't have Umbraco.Web in the usings, which makes SetContentLastChanceFinder() throw a missing error.
Quick question: I'm trying to get Umbraco v8 to force Tls1.2 as its default protocol and assumed that putting a component .CS file in App_Code was the right place for that, but you're saying it should go elsewhere maybe? Not well-versed in the new Components structure so am a bit lost.
using System.Net;
using Umbraco.Core;
using Umbraco.Core.Composing;
namespace My.Website
{
[RuntimeLevel(MinLevel = RuntimeLevel.Run)]
public class MyComposer : ComponentComposer<MyComponent>
{
//this automatically adds the component to the Components collection of the Umbraco composition
}
public class MyComponent : IComponent
{
// initialize: runs once when Umbraco starts
public void Initialize()
{
if (ServicePointManager.SecurityProtocol.HasFlag(SecurityProtocolType.Tls12) == false)
{
ServicePointManager.SecurityProtocol = ServicePointManager.SecurityProtocol | SecurityProtocolType.Tls12;
}
}
// terminate: runs once when Umbraco stops
public void Terminate()
{
}
}
}
Porting packages to V8 - New Composer & Component way
Following the article entitled https://our.umbraco.com/documentation/Tutorials/Porting-Packages-V8/ section 'New Composer & Component way' I have changed my code accordingly, but now get a compilation error (see screen snippet).
Please advise.
Hi Rob,
I've had a similar issue and fixed it by changing
Umbraco.Core.Components
toUmbraco.Core.Composing
. Also, implementing the code in the documentation I figured that you also need to useUmbraco.Web
.Thanks, docs updates with the correct namespace now 👍
I created a pull request for that, should I delete it (https://github.com/umbraco/UmbracoDocs/pull/1616)? Also, the docs still don't have
Umbraco.Web
in the usings, which makesSetContentLastChanceFinder()
throw a missing error.Thanks Koen that's done the trick
I would suggest not putting code in App_Code, and if you do, try to compile your website to make sure the code actually compiles :)
Quick question: I'm trying to get Umbraco v8 to force Tls1.2 as its default protocol and assumed that putting a component .CS file in App_Code was the right place for that, but you're saying it should go elsewhere maybe? Not well-versed in the new Components structure so am a bit lost.
This will work on v8:
is working on a reply...