Answer the question
In order to leave comments, you need to log in
Why is OnPost request not working?
I started to study Asp Net Core 2. There is a razor page and the post request does not work in it: when you click on the button, it displays that the page is not available. If you send the get form with a request, then everything works. What am I doing wrong?
And how can you specify which handler the form should be processed with? I saw a way through asp-page-handler, but it didn’t work for me (I managed to connect only through a hidden tag)
@page
@functions
{
public string Number1 {get; set;}
public void OnPost(string numb2)
{
Model.Number1=numb2;
}
public void OnPostCalc(string numb1)
{
Model.Number1=numb1;
}
}
<!DOCTYPE html>
<html>
<head>
<title>Razor Pages</title>
</head>
<body>
<p>Здравствуйте! @Model.Number1</p>
<form method="post" name="form1">
<input type="hidden" name="handler" value="calc"/>
<input type="text" name="numb1"/>
<input type="text" name="numb2"/>
<input type="submit" value="Посчитать" name="sub"/>
</form>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question