DevInstance.WebServiceToolkit 10.0.1

dotnet add package DevInstance.WebServiceToolkit --version 10.0.1
                    
NuGet\Install-Package DevInstance.WebServiceToolkit -Version 10.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DevInstance.WebServiceToolkit" Version="10.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DevInstance.WebServiceToolkit" Version="10.0.1" />
                    
Directory.Packages.props
<PackageReference Include="DevInstance.WebServiceToolkit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DevInstance.WebServiceToolkit --version 10.0.1
                    
#r "nuget: DevInstance.WebServiceToolkit, 10.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DevInstance.WebServiceToolkit@10.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DevInstance.WebServiceToolkit&version=10.0.1
                    
Install as a Cake Addin
#tool nuget:?package=DevInstance.WebServiceToolkit&version=10.0.1
                    
Install as a Cake Tool

DevInstance.WebServiceToolkit

ASP.NET Core utilities for web service development including query model binding, exception handling, and service registration.

Installation

dotnet add package DevInstance.WebServiceToolkit

This package includes DevInstance.WebServiceToolkit.Common and DevInstance.WebServiceToolkit.Database as dependencies.

Features

  • Query Model Binding - Automatic binding of query string parameters to strongly-typed POCOs
  • Exception Handling - Standardized HTTP exception types with automatic response mapping
  • Service Registration - Attribute-based automatic dependency injection

Quick Start

1. Configure Services

using DevInstance.WebServiceToolkit.Http.Query;
using DevInstance.WebServiceToolkit.Tools;

var builder = WebApplication.CreateBuilder(args);

// Add query model binding support
builder.Services.AddControllers()
    .AddWebServiceToolkitQuery();

// Auto-register services marked with [WebService]
builder.Services.AddServerWebServices();

2. Query Model Binding

Define query models with the [QueryModel] attribute:

using DevInstance.WebServiceToolkit.Http.Query;
using System.ComponentModel;

[QueryModel]
public class ProductQuery
{
    [DefaultValue(0)]
    public int Page { get; set; }

    [DefaultValue(20)]
    public int PageSize { get; set; }

    public string? Search { get; set; }

    [QueryName("sort")]
    public string? SortBy { get; set; }
}

Use in controllers - binding happens automatically:

[HttpGet]
public ActionResult<ModelList<Product>> GetProducts(ProductQuery query)
{
    // query is populated from ?page=0&pageSize=20&search=widget&sort=name
}

3. Exception Handling

Use HandleWebRequestAsync to automatically convert exceptions to HTTP responses:

using DevInstance.WebServiceToolkit.Controllers;
using DevInstance.WebServiceToolkit.Exceptions;

[HttpGet("{id}")]
public Task<ActionResult<Product>> GetProduct(string id)
{
    return this.HandleWebRequestAsync<Product>(async () =>
    {
        var product = await _productService.GetByIdAsync(id);
        if (product == null)
            throw new RecordNotFoundException(id);  // Returns 404
        return Ok(product);
    });
}

Exception to HTTP Status Mapping:

Exception HTTP Status
RecordNotFoundException 404 Not Found
RecordConflictException 409 Conflict
UnauthorizedException 401 Unauthorized
BadRequestException 400 Bad Request
Other exceptions 500 with Problem Details

4. Service Registration

Mark services for automatic DI registration:

using DevInstance.WebServiceToolkit.Tools;

public interface IProductService
{
    Task<Product?> GetByIdAsync(string id);
}

[WebService]
public class ProductService : IProductService
{
    // Automatically registered as scoped service
}

// For testing, use WebServiceMock
[WebServiceMock]
public class MockProductService : IProductService
{
    // Register with AddServerWebServicesMocks()
}

Register services:

// Production
builder.Services.AddServerWebServices();

// Testing
builder.Services.AddServerWebServicesMocks();

API Reference

Query Model Binding

Type Description
QueryModelBinder Core query string parsing engine
QueryModelBindException Exception with per-field validation errors
QueryModelBinderProvider MVC model binder provider
QueryModelMvcBinder MVC model binder implementation
RegistrationExtensions DI registration extension methods

Exceptions

Type HTTP Status Description
BadRequestException 400 Invalid request data
UnauthorizedException 401 Authentication required
RecordNotFoundException 404 Resource not found
RecordConflictException 409 Resource conflict

Controllers

Type Description
ControllerUtils Extension methods for exception handling

Service Registration

Type Description
WebServiceAttribute Marks a class for automatic DI registration
WebServiceMockAttribute Marks a mock implementation for testing
ServiceConfigurationExtensions Assembly scanning and registration

See Also

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.1 74 1/20/2026
10.0.0 254 11/10/2025
9.0.1 170 10/8/2025
9.0.0 127 10/3/2025
8.3.0 138 1/16/2025
8.2.0 133 1/16/2025
8.1.0 163 1/2/2025
8.0.0 155 12/18/2024
6.0.0 182 3/20/2025