While my server-side Blazor app is running, I want some Javascript code in _Host.cshtml to be able to post data to a controller action. Of course, this happens completely outside of the scope of, and is unrelated to, the Blazor app itself.
I thought this would be a matter of adding calls to services.AddControllers() and endpoints.MapControllers() at the appropriate places in Startup.cs. However, after doing this, and implementing the controller action, I made the following observations:
- Requests to the action are not routed and treated as "not found"
- In Razor,
@Url.Actionon the controller action returns a blank string
How can I add controller (not view) support to my server-side Blazor project in a way that overcomes the above two issues?