我的控制器上有很多操作,如果可能的话,我只想将特定路由用于一个操作。我正在寻找一种方法来覆盖在控制器级别定义的路由。
[Route("api/candidate/attached-file")]
public class AttachedFileController : Controller
{
//overriding controller route
[HttpPost("api/candidate/{id}/attached-file")]
public async Task<IActionResult> AttachFile(string id, [FromBody] AttachedFile file)
{
...
}
//using controller route
[HttpGet("{id}")]
public ActionResult Get(string id) {}
[HttpGet]
public ActionResult GetAll() {}
...
}
Run Code Online (Sandbox Code Playgroud) I'm trying to get file upload progress inside a blazor web assembly app.
var handler = new ProgressMessageHandler();
handler.InnerHandler = new WebAssemblyHttpMessageHandler();
handler.HttpSendProgress += (object sender, HttpProgressEventArgs e) =>
{
Console.WriteLine("bytes transfered= " + e.BytesTransferred.ToString());
Console.WriteLine("total bytes= " + e.TotalBytes.ToString());
Console.WriteLine("progress percentage= " + e.ProgressPercentage.ToString());
};
var http = new HttpClient(handler);
http.BaseAddress = new Uri(NavigationManager.BaseUri);
await http.PostJsonAsync("api/...", attachedFile);
Console.WriteLine("Done");
Run Code Online (Sandbox Code Playgroud)
I came up with the following code, but when I upload a file I get a single event instantly reporting 100% …