0

In order to be able to serve audio from a SqlServer database in a Blazor project I need to have an IHttpHandler in the project. I could add an AudioHandler.ashx and AudioHandler.ashx.cs file to the project, but what else (NuGet package for instance) do I need to add in order to be able to use the IHttpHandler interface like:

public class AudioHandler : IHttpHandler
{
}

And how can I register this handler so it can be called from Javascript?

Thanks a lot in advance!

  • 1
    Can you describe your architecture a bit better? Blazor runs in the browser as WebAssembly. If you add an IHttpHandler to your Blazor app, the browser will now host a web server, but that won't connect to your SQL Server over the internet. Don't you just want a Web API that does this? You don't need a handler for that. See also https://learn.microsoft.com/en-us/dotnet/architecture/blazor-for-web-forms-developers/migration#migrate-http-modules-and-handlers-to-middleware – CodeCaster Dec 02 '20 at 09:20
  • Thanks CodeCaster, that was very helpful. I used your link, plus the link in it (https://learn.microsoft.com/en-us/aspnet/core/migration/http-modules?view=aspnetcore-5.0) and another link to solve some error messages (https://stackoverflow.com/questions/42199757/enable-options-header-for-cors-on-net-core-web-api). I got it working now! Cheers! – Paul ten Brink Dec 02 '20 at 13:41

0 Answers0