Table of Contents

Interface IDynamicWebApi


This interface extends WebAPIs with File-Save helpers. It's important, because if 2sxc also runs on other CMS platforms, then the Dnn Context won't be available, so it's in a separate interface.

public interface IDynamicWebApi


File(NoParamOrder, bool?, string, string, string, object)

Create a File-result to stream to the client

Typical use: return File(download: true, contentType: "text/xml", contents: ...);

dynamic File(NoParamOrder noParamOrder = default, bool? download = null, string virtualPath = null, string contentType = null, string fileDownloadName = null, object contents = null)


noParamOrder NoParamOrder

see Convention: Named Parameters

download bool?

If a download should be enforced (otherwise the file may just be displayed - like an image)

virtualPath string

Path in the website to get the file from. Provide either virtualPath or contents

contentType string

Mime Content-type. Will try to auto-detect from virtualPath or fileDownloadName if not provided.

fileDownloadName string

Download name. If provided, it will try to force download/save on the browser.

contents object

Content of the result - a string, byte[] or stream to include.




Added in 2sxc 12.05

SaveInAdam(NoParamOrder, Stream, string, string, Guid?, string, string)

Save a file from a stream (usually an upload from the browser) into an adam-field of an item. Read more about this in the the WebAPI docs for SaveInAdam

IFile SaveInAdam(NoParamOrder noParamOrder = default, Stream stream = null, string fileName = null, string contentType = null, Guid? guid = null, string field = null, string subFolder = "")


noParamOrder NoParamOrder

see Convention: Named Parameters

stream Stream

the stream

fileName string

file name to save to

contentType string

content-type of the target item (important for security checks)

guid Guid?
field string
subFolder string