Open Closed

Blazoe WebApp Request Validation Failing #9998


User avatar
0
ddelamare created

I am having this issue where requests that work when using Blazor Server rendering fail when the page is rendered in WebAssembly Mode.

There are two similar errors I'm encountering.

1. There is an API call that uses `[DisableValidation]`, and it works normally when using InteractiveServer, but not InteractiveAuto. It seems to fail in the generated controller, before reaching the proxy. No breakpoints or logging from the proxies are happening, and the 400 response from the server has no text. Is there a way to disable this eager validation and wait until it hits the api?
2. The is an API call that uploads a file using a using file upload dto, which again works when using InteractiveServer, but not InteractiveAuto. The error returned is Unsupported Media Type. Is there a way t fix this or disable it?

2 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    1. For the issue with [DisableValidation] and 400 errors in WebAssembly (WASM) mode:

      • In Blazor WASM (especially with prerendering or InteractiveAuto), validation may occur on the client before the request reaches your API. ABP's generated proxies and validation pipeline can behave differently between server and WASM modes. If you want to ensure validation only happens on the server, avoid using client-side proxies for these calls, or use direct HTTP requests (e.g., via HttpClient) to your API endpoints. This bypasses the client-side validation layer and ensures the [DisableValidation] attribute is respected server-side.
      • There is no built-in ABP option to globally disable client-side validation for all proxies in WASM mode. You must either avoid using the generated proxy for that endpoint or customize the proxy/service code to skip validation.
    2. For the file upload API returning "Unsupported Media Type" in WASM mode:

      • This error typically occurs if the request's Content-Type does not match what the API expects (e.g., multipart/form-data for file uploads). In Blazor WASM, ensure you are using IBrowserFile and MultipartFormDataContent when sending files, and that your API action is decorated with [Consumes("multipart/form-data")].
      • If you are using ABP's auto-generated proxies, they may not handle file uploads correctly in WASM mode. In such cases, use HttpClient directly to construct and send the multipart request.

    Example for file upload in Blazor WASM:

    var content = new MultipartFormDataContent();
    content.Add(new StreamContent(file.OpenReadStream()), "File", file.Name);
    await httpClient.PostAsync("api/your-endpoint", content);
    

    And in your API controller:

    [HttpPost]
    [Consumes("multipart/form-data")]
    public async Task<IActionResult> Upload([FromForm] YourFileUploadDto input)
    {
        // handle file
    }
    

    Summary:

    • For [DisableValidation], use direct HTTP calls for endpoints where you want to avoid client-side validation.
    • For file uploads, use HttpClient with MultipartFormDataContent and ensure your API expects multipart/form-data.

    Sources:


    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    ddelamare created

    I am not able to call the API directly since the new WebApp model applies credentials in the Blazor server before forwarding to the API. Having to maintain custom http client calls is also not acceptable overhead.

    I can see the requests being fired so the validation is not happening in the brower.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on October 15, 2025, 07:46