In SaaS → Tenants → Actions → Connection strings, clicking Test next to the default connection string shows the error 415 Unsupported Media Type, even when the connection string is valid.
The problem happens when the application is running in WebAssembly mode, but not in server mode.
Steps to reproduce
1. Server mode —> works
- Open a private window and sign in to the application.
- Go to SaaS → Tenants → Actions → Connection strings.
- Uncheck Use the shared database and fill in a valid connection string.
- Click Test.
- Confirm that the test runs successfully.
2. WebAssembly mode —> fails
- In the same window, reload the page with F5.
- Repeat the test with the same connection string.
- Confirm that the error 415 Unsupported Media Type is shown.
1 Answer(s)
-
0
Hi,
In WebAssembly mode the request goes through your
Blazorproject, and that forwarding endpoint loses the connection string, so theHttpApi.Hostreturns 415.You can fix it in your
Blazorproject for now. Add this class:using System.Linq; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ApplicationModels; using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.Extensions.Options; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.Conventions; using Volo.Abp.DependencyInjection; using Volo.Abp.Http.Client.ClientProxying; using Volo.Abp.Http.Client.StaticProxying; using Volo.Abp.Http.Client.Web.Conventions; using Volo.Abp.Http.ProxyScripting.Generators; [DisableConventionalRegistration] public class MyHttpClientProxyServiceConvention : AbpHttpClientProxyServiceConvention { public MyHttpClientProxyServiceConvention( IOptions<AbpAspNetCoreMvcOptions> options, IConventionalRouteBuilder conventionalRouteBuilder, IClientProxyApiDescriptionFinder clientProxyApiDescriptionFinder, IOptions<AbpHttpClientStaticProxyingOptions> staticProxyingOptions) : base(options, conventionalRouteBuilder, clientProxyApiDescriptionFinder, staticProxyingOptions) { } protected override void ConfigureParameters(ControllerModel controller) { if (AbpHttpClientProxyHelper.IsClientProxyService(controller.ControllerType)) { foreach (var action in controller.Actions) { var actionApiDescription = FindActionApiDescriptionModel(controller, action); if (actionApiDescription == null) { continue; } foreach (var parameter in action.Parameters.Where(p => p.BindingInfo == null)) { if (actionApiDescription.Parameters.Any(p => p.NameOnMethod == parameter.ParameterName && p.BindingSourceId == ParameterBindingSources.Body)) { parameter.BindingInfo = BindingInfo.GetBindingInfo(new[] { new FromBodyAttribute() }); } } } } base.ConfigureParameters(controller); } }Then register it in
ConfigureServicesof your...BlazorModule:context.Services.Replace(ServiceDescriptor.Transient<IAbpServiceConvention, MyHttpClientProxyServiceConvention>());This needs
using Microsoft.Extensions.DependencyInjection.Extensions;andusing Volo.Abp.AspNetCore.Mvc.Conventions;.We'll fix this in the next patch version. Your ticket has been refunded.
Thanks
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)