Jump to content
Sign in to follow this  
Sirinoks

Recreating Razor pages example

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

Share this post


Link to post
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"];

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...