I'm trying to follow the Microsoft Docs on getting started with Razor. When I try to implement the following code I get the errors detailed in the comments:
Solution/Project/Pages/AddNumbers.cshtml :
@{
var total = 0;
var totalMessage = "";
if(IsPost) { // The name 'isPost' does not exist in the current context
// Retrieve the numbers that the user entered.
var num1 = Request["text1"]; // CS0103 The name 'Request' does not exist in the current context
var num2 = Request["text2"]; // CS0103 The name 'Request' does not exist in the current context
// Convert the entered strings into integers numbers and add.
total = num1.AsInt() + num2.AsInt();
totalMessage = "Total = " + total;
}
}
I think I've followed the instructions faithfully, but can't think where I've made an error. What's the fix?