Table of Contents
These v19 docs are archived 🔒. Go to the latest docs home or try if this exact page is available in the latest docs.

Class DnnExtensions

Namespace
ToSic.Sxc.Services
Assembly
ToSic.Sxc.Dnn.Core.dll

Provides extension methods for DNN Skins (Themes) and Modules. It only exists on the Dnn platform, not on Oqtane.

[PublicApi]
public static class DnnExtensions
Inheritance
object
DnnExtensions

Remarks

Created v14

Methods

GetScopedService<T>()

Get a service from the current HTTP Scope. This is the standalone method.

public static T GetScopedService<T>()

Returns

T

A service of type T - if it can be found. Otherwise it will throw an error.

Type Parameters

T

Remarks

This requires an HttpContext.Current to exist, so it will not work within a search controller.

History

  • Created in v14
  • In v15.03 added special patch so it work on 404 pages where the service provider is broken/not available

GetScopedService<T>(UserControl)

Helper extension method to get a scoped service on a skin/theme or module.

To call it you must prefix it with this. like this.GetScopedService...

public static T GetScopedService<T>(this UserControl skinOrModule)

Parameters

skinOrModule UserControl

Returns

T

Type Parameters

T

Remarks

This requires an HttpContext.Current to exist, so it will not work within a search controller.

History

  • Created in v14