Structr
  • Welcome
  • Utilities
    • Abstractions
      • Check
      • Ensure
      • Money
      • HierarchyId
      • Providers
        • SequentialGuidProvider
      • Extensions
        • DateTime
        • Dictionary
        • DirectoryInfo
        • Enumerable
        • Enum
        • Expression
        • Int
        • Long
        • MemberInfo
        • Object
        • Queryable
        • ServiceCollection
        • String
        • Type
      • Helpers
        • AsyncHelper
        • BindHelper
      • JsonConverters
        • DateOnly
        • TimeOnly
        • StringNumber
    • Collections
      • AutoMapper extensions
    • IO
      • FileHelper
      • MimeTypeHelper
      • PathHelper
      • SequentialFileName
    • Configuration
      • Providers
        • JSON-file
        • XML-file
        • In-Memory
        • Consul
      • Get settings
      • Set settings
      • Customization
    • Email
      • Razor
    • Navigation
      • Menu
      • Breadcrumbs
    • Security
  • Domain
    • Domain
      • Entities
      • Value objects
  • Data Access
    • Entity Framework Core
    • Entity Framework 6
  • Use Cases
    • Operations
      • Filtering
      • Decoration
    • Notices
    • Validation
    • Specifications
    • Stateflows
      • StateMachine
      • Configurations
  • Presentation
    • ASP.NET Core
      • Client
      • Http
      • JavaScript
      • Json
      • Mvc
      • Referrer
      • Rewrite
      • Routing
      • TagHelpers
      • Validation
Powered by GitBook
On this page
  • JsonResponse
  • JsonResponseError
  • JavaScriptController extensions

Was this helpful?

Edit on GitHub
  1. Presentation
  2. ASP.NET Core

Json

PreviousJavaScriptNextMvc

Last updated 2 years ago

Was this helpful?

This part provides json-related controller extensions and actions results.

JsonResponse

JsonResponse class represents a result containing data object, errors list, message and success marker. It has following properties:

Property name
Property type
Description

Ok

bool

true when there are no errors in result, otherwise false.

Message

string

A message supplementing the result. Contains text of specified message or first error's message or null in case of no errors.

Data

object

A data attached to result;

Errors

A list of errors contained in result;

The class has different constructors allowing to specify this properties in different combinations.

Working with class is performed by using controller extension that wrap instances of JsonResponse with JsonResult.

JsonResponseError

This class represents an error to be transferred to a client.

Property name
Property type
Description

Key

string

Key corresponding to an error.

Message

string

Message corresponding to an error.

JavaScriptController extensions

These extension methods provide possibilities of sending JsonResponse wrapped in JsonResult:

Method name
Return type
Description

JsonResponse

JsonResponse

Creates a JsonResult object, with serialized success marker, message and data.

There are several overloads of this method taking as parameters the success marker, message, errors list and data.

methods
IEnumerable<JsonResponseError>