Class HtmlPage
Access the surrounding page and read/modify some properties, and add various kinds of headers to the <head> of the current page.
Inheritance
Namespace: ToSic.Razor.Blade
Assembly: ToSic.Razor.Dnn.dll
Syntax
[Obsolete("This used to be a good idea, but doesn't scale well with blazor. Please use the newer ToSic.Sxc.Web.IPageService instead.")]
public static class HtmlPage
Remarks
This is now obsolete. The concept doesn't scale with Blazor (.net core), so we recommend you use the newer ToSic.Sxc.Web.IPageService instead.
Properties
| Improve this Doc View SourceDescription
Get/Set description of this page Will return null if not running in a page context.
Declaration
public static string Description { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Keywords
Get/Set keywords of this page Will return null if not running in a page context.
Declaration
public static string Keywords { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Title
The current page title Will return null if not running in a page context.
Declaration
public static string Title { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Methods
| Improve this Doc View SourceAddBase(String)
Add a standard base header tag. new in 3.0
Declaration
public static void AddBase(string url = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | the optional url for the base tag - if null, will default to the real url for the current page |
AddIcon(String, String, String, Int32, String)
Add an icon tag to the page new in 3.0
Declaration
public static void AddIcon(string path, string doNotRelyOnParameterOrder = "Dummy-Parameter - don't provide this, but do name all other parameters in this call using paramName: value", string rel = "", int size = 0, string type = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Path to the image/icon file |
System.String | doNotRelyOnParameterOrder | This is a dummy parameter to force the developer to name the remaining parameters - like size: 75 etc. This allows us to add more parameters in future without worrying that existing code could break. |
System.String | rel | the rel-text, default is 'icon'. common terms are also 'shortcut icon' or 'apple-touch-icon' |
System.Int32 | size | Will be used in size='#x#' tag; only relevant if you want to provide multiple separate sizes |
System.String | type | An optional type. If not provided, will be auto-detected from known types or remain empty |
AddIconSet(String, String, Object, IEnumerable<String>, IEnumerable<Int32>)
Add a set of icons to the page new in 3.0
Declaration
public static void AddIconSet(string path, string doNotRelyOnParameterOrder = "Dummy-Parameter - don't provide this, but do name all other parameters in this call using paramName: value", object favicon = null, IEnumerable<string> rels = null, IEnumerable<int> sizes = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Path to the image/icon file |
System.String | doNotRelyOnParameterOrder | This is a dummy parameter to force the developer to name the remaining parameters - like size: 75 etc. This allows us to add more parameters in future without worrying that existing code could break. |
System.Object | favicon | path to favicon, default is '/favicon.ico' |
System.Collections.Generic.IEnumerable<System.String> | rels | |
System.Collections.Generic.IEnumerable<System.Int32> | sizes |
AddJsonLd(Object)
Add a JSON-LD header according https://developers.google.com/search/docs/guides/intro-structured-data
Declaration
public static void AddJsonLd(object jsonObject)
Parameters
Type | Name | Description |
---|---|---|
System.Object | jsonObject | A object which will be converted to JSON. We recommend using dictionaries to build the object. |
AddJsonLd(String)
Add a JSON-LD header according https://developers.google.com/search/docs/guides/intro-structured-data
Declaration
public static void AddJsonLd(string jsonString)
Parameters
Type | Name | Description |
---|---|---|
System.String | jsonString | A prepared JSON string |
AddMeta(String, String)
Add a standard meta header tag. If you need to add more attributes, use AddHeader(...) instead
Declaration
public static void AddMeta(string name, string content)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | |
System.String | content |
AddOpenGraph(String, String)
Add an open-graph header according to http://ogp.me/
Declaration
public static void AddOpenGraph(string property, string content)
Parameters
Type | Name | Description |
---|---|---|
System.String | property | Open Graph property name, like title or image:width. 'og:' is automatically prefixed if not included |
System.String | content | value of this property |
AddToHead(String)
Add a tag to the header of the page Will simply not do anything if an error occurs, like if the page object doesn't exist
Declaration
public static void AddToHead(string tag)
Parameters
Type | Name | Description |
---|---|---|
System.String | tag |
AddToHead(TagBase)
Add a tag object to the header of the page Will simply not do anything if an error occurs, like if the page object doesn't exist
Declaration
public static void AddToHead(TagBase tag)
Parameters
Type | Name | Description |
---|---|---|
TagBase | tag |
Remarks
New in 2.1
GetPage()
Declaration
public static IHtmlPage GetPage()
Returns
Type | Description |
---|---|
ToSic.Razor.Interfaces.IHtmlPage |