Then give me an example of how I can block the current View() in the browser or close it with a transparent background with the inscription "Waiting..." so that a person does not click on all the buttons during a long request?
JavaScript to the recuse...
The script toggles the CSS display property which hides the form and shows the Waiting prompt. The response from the Method action replaces the page content.
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<div id="myform">
<form method="post" action="/Home/Method">
<input type="submit" name="submit" value="submit" />
</form>
</div>
<div id="waiting" style="display:none;">
Waiting...
</div>
</div>
@section scripts {
<script>
addEventListener('submit', (event) => {
document.getElementById("myform").style.setProperty("display", "none");
document.getElementById("waiting").style.removeProperty("display")
});
</script>
}
[HttpGet]
public IActionResult Index()
{
return View();
}
[HttpPost]
public async Task<IActionResult> Method()
{
await AsyncDo();
return View();
}
private async Task AsyncDo()
{
await Task.Delay(1000 * 3);
}