Class SearchEngineFriendlyURLs
- Namespace
- Dynamicweb.Frontend
- Assembly
- Dynamicweb.dll
Helper methods for handling search friendly urls.
public static class SearchEngineFriendlyURLs
- Inheritance
-
SearchEngineFriendlyURLs
- Inherited Members
Properties
RedirectType
Gets the type of the search engine friendly url.
public static SearchEngineFriendlyURLs.Type RedirectType { get; }
Property Value
- SearchEngineFriendlyURLs.Type
The type of the redirect.
UseExtensionLessUrls
Gets a value indicating whether the solution uses extension less urls.
public static bool UseExtensionLessUrls { get; }
Property Value
- bool
trueif extension less urls should be used; otherwise,false.
Remarks
Does not return the value of the setting in GlobalSettings. Only returns true if the option is set, the application pool is integrated and the the URL schema is Path
Methods
GetFriendlyUrl(int)
Used for getting a searchfriendly version of a Dynamicweb url with just the PageID
public static string GetFriendlyUrl(int pageID)
Parameters
pageIDintID of page
Returns
- string
The searchfriendly url to the specified PageID, i.e: /Products/Product1.aspx
GetFriendlyUrl(int, string?)
Used for getting a searchfriendly version of a Dynamicweb url with just the PageID
public static string GetFriendlyUrl(int pageID, string? alternatekey)
Parameters
pageIDintID of page
alternatekeystringThe alternate key to use for module url lookups if the context will not be used. Usually an Ecommerce languageId (LANG1). The alternate key will be taken from context if it is not specified.
Returns
- string
The searchfriendly url to the specified PageID, i.e: /Products/Product1.aspx
Remarks
Use this overload if you want to resolve a URL from i.e. an English language context to the same products German context. Pass in the language id of the German context
GetFriendlyUrl(string)
Used for getting a searchfriendly version of a Dynamicweb url with all parameters
public static string GetFriendlyUrl(string internalLink)
Parameters
internalLinkstringThe internal link, i.e. Default.aspx?ID=123&NewsID=456&action=1.
Returns
- string
/module/news/NameOfNews.aspx?action=1
GetFriendlyUrl(string, string?)
Used for getting a searchfriendly version of a Dynamicweb url with all parameters
public static string GetFriendlyUrl(string internalLink, string? alternatekey)
Parameters
internalLinkstringThe internal link, i.e. Default.aspx?ID=123&NewsID=456&action=1.
alternatekeystringThe alternate key to use for module url lookups if the context will not be used. Usually an Ecommerce languageId (LANG1). The alternate key will be taken from context if it is not specified.
Returns
- string
/module/news/NameOfNews.aspx?action=1
Remarks
Use this overload if you want to resolve a URL from i.e. an English language context to the same products German context. Pass in the language id of the German context
GetFriendlyUrlWithAreaHostname(int, bool, string)
Gets a friendly URL with the correct hostname for a page, taking into account area domain locks.
public static Uri GetFriendlyUrlWithAreaHostname(int pageId, bool isSsl, string currentHostName)
Parameters
pageIdintThe ID of the page to get the URL for.
isSslboolWhether to use HTTPS (true) or HTTP (false) for the URL scheme.
currentHostNamestringThe current hostname to use as fallback if no domain lock exists.
Returns
- Uri
An absolute URI if the page exists and can be resolved, containing:
- The correct scheme (http/https)
- The area's domain lock if specified, otherwise the current hostname
- The friendly URL path for the page If the page doesn't exist, returns a relative URI with the default page format.
Remarks
This method combines hostname resolution with friendly URL generation to create complete URLs that respect area domain locks and SSL settings.
TryGetFriendlyUrl(int, string?, out string?)
Thies to get a searchfriendly version of a Dynamicweb url with just the Page ID.
public static bool TryGetFriendlyUrl(int pageId, string? alternatekey, out string? result)
Parameters
pageIdintThe ID of a page.
alternatekeystringThe alternate key to use for module url lookups if the context will not be used. Usually an Ecommerce languageId (LANG1). The alternate key will be taken from context if it is not specified.
resultstringWhen the method returns
true, contains the searchfriendly url associated with the Page, ornullif the operation failed.
Returns
- bool
Truewhen the searchfriendly url of the specified Page ID exists (i.e: /Products/Product1.aspx), otherwicefalse.
TryGetFriendlyUrl(int, out string?)
Thies to get a searchfriendly version of a Dynamicweb url with just the Page ID.
public static bool TryGetFriendlyUrl(int pageId, out string? result)
Parameters
pageIdintThe ID of a page.
resultstringWhen the method returns
true, contains the searchfriendly url associated with the Page, ornullif the operation failed.
Returns
- bool
Truewhen the searchfriendly url of the specified Page ID exists (i.e: /Products/Product1.aspx), otherwicefalse.