Documentation > CMS Template API Library > Asset > Publish(Boolean,String)

Publish

Publish the asset. If we are in a session, it will reuse the same session, otherwise a new session is created. Only files are currently supported.

public System.Boolean Publish(Boolean,String)


Returns

True if successful. If false, check the context.Error for the error message.

Parameters

NameDescriptionType
publishDependencies Optional: pass true to include dependencies. Defaults to false. System.Boolean
args Optional: publishing arguments like _pageNum=1. Defaults to empty string. System.String

Code Example

C#

Sample:
	Asset myAsset = Asset.Load("/PathTo/Asset");
	if(myAsset.IsLoaded)
	{
		if(!myAsset.Publish(false))
		{
			Out.WriteLine("Error: " + context.Error);
		}
	}

Connect with Crownpeak