Jump to content

Recreating Razor pages example


Sirinoks

Recommended Posts

I was trying to learn Razor pages. I use Visual Studio, but I'm pretty new to it. I followed an official getting started guide for installation process - https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/razor-pages-start?view=aspnetcore-2.2&tabs=visual-studio . Then I tried implementing an example of w3schools - https://www.w3schools.com/asp/razor_syntax.asp - "Reading User Input". VS seemed to not recognize it - it gave me errors. I did install and add "Microsoft.AspNetCore.Mvc.Razor" through NuGet (also tried installing version 2.1.3 and latest 2.2.0) and I also added "using Microsoft.AspNetCore.Mvc.Razor;" to the Startup.cs - still nothing. Maybe I need to connect it somehow? 

Visual studio 2017 | ASP .NET Core 2.1 

Please help!

Screenshot_56.png

Link to comment
Share on other sites

I just had a poke around. The tutorials use ASP.NET Web Pages 3.2 apparently.

ASP.NET Core 2.1 may require something a little different.

Instead of ifPost (which looks like its erroring too) try

if (HttpMethods.IsPost(Request.Method))

In terms of the Request stuff, try something like this

var num1 = Request.Form["text1"];
var num2 = Request.Form["text2"];

 

Link to comment
Share on other sites

  • 10 months later...

If you  use aspnetcore then pass its Httpmethods calls and after Ispost calls and you pass this method the parameter pass in IsPost method is request.method

@{

if(HttpMethods.IsPost(Request.Method))

{

var num1=Request.Form["text1"];

var num2 = Request.Form["text2"];

}

}

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...