Click or drag to resize

EmbeddedResourcePathProviderMapResourceToWebApplication Method

Maps an embedded resource ID into a web application relative path (~/path).

Namespace: GSF.Web.Hosting
Assembly: GSF.Web (in GSF.Web.dll) Version: 2.4.181-beta
Syntax
protected static string MapResourceToWebApplication(
	string baseNamespace,
	string resourcePath
)
View Source

Parameters

baseNamespace  String
The base namespace of the resource to map.
resourcePath  String
The fully qualified embedded resource path to map.

Return Value

String
The mapped path of the resource into the web application.
Exceptions
ExceptionCondition
ArgumentNullException Thrown if baseNamespace or resourcePath is .
ArgumentOutOfRangeException Thrown if baseNamespace or resourcePath:
  • Is Empty.
  • Start or end with period.
  • Contain two or more periods together (like MyNamespace..MySubnamespace).
Remarks

The baseNamespace is stripped from the front of the resourcePath and all but the last period in the remaining resourcePath is replaced with the directory separator character ('/'). Finally, that path is mapped into a web application relative path.

The filename being mapped must have an extension associated with it, and that extension may not have a period in it. Only one period will be kept in the mapped filename - others will be assumed to be directory separators. If a filename has multiple extensions (i.e., My.Custom.config), it will not map properly - it will end up being ~/My/Custom.config.

If baseNamespace does not occur at the start of the resourcePath, an InvalidOperationException is thrown.

Example

Given a baseNamespace of MyNamespace, this method will process resourcePath as follows:

resourcePath valueMapping in Web App
MyNamespace.Config.MyFile.config~/Config/MyFile.config
MyNamespace.MyPage.aspx~/MyPage.aspx
See Also