Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to add controller (not view) support to a server-side Blazor project

$
0
0

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.Action on 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?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>