Class ApiCoreShim
This is the base class for other base-classes of modern custom API Controllers.
It provides Commands such as Ok()
which already exist in .net core and allows hybrid controllers to have the same commands.
Warning
Do not inherit from this class, it's included in the docs so you can see the APIs the other base classes have.
Use Custom.Hybrid.Api12
or Custom.Hybrid.Api14
as your real base classes
Inheritance
Namespace: ToSic.Sxc.WebApi
Assembly: ToSic.Sxc.Dnn.WebApi.dll
Syntax
[InternalApi_DoNotUse_MayChangeWithoutNotice("This is the .net core Shim class for v12+")]
public abstract class ApiCoreShim : DynamicApiController, IHttpController, IDisposable, IHasLog, ICreateInstance, IDynamicWebApi, IHasDynamicCodeRoot, IDynamicCodeBeforeV10
Constructors
| Improve this Doc View SourceApiCoreShim(String)
Declaration
protected ApiCoreShim(string logSuffix)
Parameters
Type | Name | Description |
---|---|---|
System.String | logSuffix |
Methods
| Improve this Doc View SourceAccepted()
Creates a .net-core like AcceptedResult
object that produces an .net-core like StatusCodes.Status202Accepted
response.
Declaration
[NonAction]
public dynamic Accepted()
Returns
Type | Description |
---|---|
System.Object | The created .net-core like |
BadRequest()
Creates an .net-core like BadRequestResult
that produces a .net-core like StatusCodes.Status400BadRequest
response.
Declaration
[NonAction]
public dynamic BadRequest()
Returns
Type | Description |
---|---|
System.Object | The created .net-core like |
Conflict()
Creates an .net-core like ConflictResult
that produces a .net-core like StatusCodes.Status409Conflict
response.
Declaration
[NonAction]
public dynamic Conflict()
Returns
Type | Description |
---|---|
System.Object | The created .net-core like |
Conflict(Object)
Creates an .net-core like ConflictObjectResult
that produces a .net-core like StatusCodes.Status409Conflict
response.
Declaration
[NonAction]
public dynamic Conflict(object error)
Parameters
Type | Name | Description |
---|---|---|
System.Object | error | Contains errors to be returned to the client. |
Returns
Type | Description |
---|---|
System.Object | The created .net-core like |
File(String, Nullable<Boolean>, String, String, String, Object)
Create a File-result to stream to the client
Declaration
public dynamic File(string noParamOrder = "Params must be named (https://r.2sxc.org/named-params)", bool? download = default(bool? ), string virtualPath = null, string contentType = null, string fileDownloadName = null, object contents = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | noParamOrder | |
System.Nullable<System.Boolean> | download | If a download should be enforced (otherwise the file may just be displayed - like an image) |
System.String | virtualPath | Path in the website to get the file from. Provide either virtualPath or contents |
System.String | contentType | Mime Content-type. Will try to auto-detect from virtualPath or fileDownloadName if not provided. |
System.String | fileDownloadName | Download name. If provided, it will try to force download/save on the browser. |
System.Object | contents | Content of the result - a string, byte[] or stream to include. |
Returns
Type | Description |
---|---|
System.Object |
Remarks
Added in 2sxc 12.05
Forbid()
Creates a .net-core like ForbidResult
(.net-core like StatusCodes.Status403Forbidden
by default).
Declaration
[NonAction]
public dynamic Forbid()
Returns
Type | Description |
---|---|
System.Object | The created .net-core like |
Remarks
Some authentication schemes, such as cookies, will convert .net-core like StatusCodes.Status403Forbidden
to
a redirect to show a login page.
NoContent()
Creates a .net-core like NoContentResult
object that produces an empty
.net-core like StatusCodes.Status204NoContent
response.
Declaration
[NonAction]
public dynamic NoContent()
Returns
Type | Description |
---|---|
System.Object | The created .net-core like |
NotFound()
Creates an .net-core like NotFoundResult
that produces a .net-core like StatusCodes.Status404NotFound
response.
Declaration
[NonAction]
public dynamic NotFound()
Returns
Type | Description |
---|---|
System.Object | The created .net-core like |
NotFound(Object)
Creates an .net-core like NotFoundObjectResult
that produces a .net-core like StatusCodes.Status404NotFound
response.
Declaration
[NonAction]
public dynamic NotFound(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value |
Returns
Type | Description |
---|---|
System.Object | The created .net-core like |
Ok()
Creates a .net-core like OkResult
object that produces an empty .net-core like StatusCodes.Status200OK
response.
Declaration
[NonAction]
public dynamic Ok()
Returns
Type | Description |
---|---|
System.Object | The created .net-core like |
Ok(Object)
Creates an .net-core like OkObjectResult
object that produces an .net-core like StatusCodes.Status200OK
response.
Declaration
[NonAction]
public dynamic Ok(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The content value to format in the entity body. |
Returns
Type | Description |
---|---|
System.Object | The created .net-core like |
Redirect(String)
Creates a .net-core like RedirectResult
object that redirects (.net-core like StatusCodes.Status302Found
)
to the specified url
.
Declaration
[NonAction]
public dynamic Redirect(string url)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | The URL to redirect to. |
Returns
Type | Description |
---|---|
System.Object | The created .net-core like |
RedirectPermanent(String)
Creates a .net-core like RedirectResult
object with .net-core like RedirectResult.Permanent
set to true
(.net-core like StatusCodes.Status301MovedPermanently
) using the specified url
.
Declaration
[NonAction]
public dynamic RedirectPermanent(string url)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | The URL to redirect to. |
Returns
Type | Description |
---|---|
System.Object | The created .net-core like |
StatusCode(Int32)
Creates a .net-core like StatusCodeResult
object by specifying a statusCode
.
Declaration
[NonAction]
public dynamic StatusCode(int statusCode)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | statusCode | The status code to set on the response. |
Returns
Type | Description |
---|---|
System.Object | The created .net-core like |
StatusCode(Int32, Object)
Creates a .net-core like ObjectResult
object by specifying a statusCode
and value
Declaration
[NonAction]
public dynamic StatusCode(int statusCode, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | statusCode | The status code to set on the response. |
System.Object | value | The value to set on the .net-core like `ObjectResult"/>. |
Returns
Type | Description |
---|---|
System.Object | The created .net-core like |
Unauthorized()
Creates an .net-core like UnauthorizedResult
that produces an .net-core like StatusCodes.Status401Unauthorized
response.
Declaration
[NonAction]
public dynamic Unauthorized()
Returns
Type | Description |
---|---|
System.Object | The created .net-core like |
Unauthorized(Object)
Creates an .net-core like UnauthorizedObjectResult
that produces a .net-core like StatusCodes.Status401Unauthorized
response.
Declaration
[NonAction]
public dynamic Unauthorized(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value |
Returns
Type | Description |
---|---|
System.Object | The created .net-core like |