Mvp.Selections.Client
4.13.1
dotnet add package Mvp.Selections.Client --version 4.13.1
NuGet\Install-Package Mvp.Selections.Client -Version 4.13.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="Mvp.Selections.Client" Version="4.13.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Mvp.Selections.Client --version 4.13.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Mvp.Selections.Client, 4.13.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.
// Install Mvp.Selections.Client as a Cake Addin
#addin nuget:?package=Mvp.Selections.Client&version=4.13.1
// Install Mvp.Selections.Client as a Cake Tool
#tool nuget:?package=Mvp.Selections.Client&version=4.13.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Sitecore MVP Selections API Client
▶️ Usage
Provide the configuration through an environment variable such as
MvpSelectionsApiClient__BaseAddress: ${MVP_SELECTIONS_API}
or by
adding it into the local.settings.json.
Create a TokenProvider:
namespace Example.Providers
{
public class HttpContextTokenProvider : ITokenProvider
{
private readonly IHttpContextAccessor _httpContextAccessor;
public HttpContextTokenProvider(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
public async Task<string> GetTokenAsync()
{
string result = string.Empty;
HttpContext context = _httpContextAccessor.HttpContext;
if (context != null)
{
result = await context.GetTokenAsync("id_token");
}
return result;
}
}
}
Register the client and your tokenprovider on Startup:
using Example.Providers;
using Microsoft.Extensions.DependencyInjection;
using Mvp.Selections.Client.Extensions;
using Mvp.Selections.Client.Interfaces;
public void ConfigureServices(IServiceCollection services)
{
services.AddScoped<ITokenProvider, HttpContextTokenProvider>();
services.AddMvpSelectionsApiClient();
}
Using the client:
namespace Example.ViewComponents
{
public class ExampleViewComponent : ViewComponent
{
private readonly MvpSelectionsApiClient _client;
protected BaseViewComponent(MvpSelectionsApiClient client)
{
_client = client;
}
public override async Task<IViewComponentResult> InvokeAsync()
{
// This example tries to fetch the list of all users
IViewComponentResult result;
Response<IList<User>> usersResponse = await _client.GetUsersAsync(model.Page, model.PageSize);
if (usersResponse.StatusCode == HttpStatusCode.OK && usersResponse.Result != null)
{
result = View(usersResponse.Result);
}
else
{
result = View();
}
return result;
}
}
}
🔨 Build
Package as a Nuget by running
dotnet pack -c Release -p:NuspecFile=Mvp.Selections.Client.nuspec
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Extensions.Http (>= 8.0.0)
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 |
---|---|---|
4.13.1 | 458 | 3/7/2024 |
4.12.1 | 567 | 2/12/2024 |
4.12.0 | 92 | 2/12/2024 |
4.10.1 | 615 | 12/4/2023 |
4.9.0 | 206 | 11/27/2023 |
4.8.0 | 86 | 11/27/2023 |
4.7.2 | 102 | 11/21/2023 |
4.7.0 | 82 | 11/21/2023 |
4.6.0 | 78 | 11/17/2023 |
4.5.1 | 76 | 11/17/2023 |
4.5.0 | 93 | 11/17/2023 |
4.4.0 | 820 | 4/7/2023 |
4.3.0 | 169 | 4/6/2023 |
4.2.1 | 581 | 1/15/2023 |
4.2.0 | 296 | 1/14/2023 |
4.1.0 | 297 | 1/14/2023 |
4.0.0 | 276 | 1/10/2023 |
3.15.0 | 344 | 1/4/2023 |
3.14.1 | 264 | 12/21/2022 |
3.14.0 | 269 | 12/21/2022 |
3.12.0 | 384 | 12/2/2022 |
3.8.0 | 301 | 11/23/2022 |
3.7.0 | 302 | 11/18/2022 |
3.5.0 | 526 | 10/7/2022 |
3.4.2 | 360 | 10/5/2022 |
3.4.1 | 399 | 10/5/2022 |
3.4.0 | 375 | 10/4/2022 |
3.3.1 | 411 | 9/30/2022 |
3.3.0 | 363 | 9/29/2022 |
3.2.0 | 375 | 9/28/2022 |
3.1.1 | 458 | 9/27/2022 |
3.1.0 | 406 | 9/21/2022 |
3.0.0 | 402 | 9/20/2022 |
2.0.0 | 401 | 9/20/2022 |
1.0.0 | 432 | 9/19/2022 |
+ MvpProfile Id