Forum Discussion
rmerritt
Jun 15, 2024Copper Contributor
read from get string?
I have a Survey,cshtml
and I want to read in the lat and long below
https://localhost:7045/Home/Survey/?lat=53.93021986394&long=-109.99511718750001
how does one do that?
- Abhishek_KhatriCopper ContributorI will check but where is the link, the link you provide its localhost its now working in my side
can you please provide link of code anything that help me to resolve your problem.
Thanks- rmerrittCopper Contributor
Sorry this is just local on my laptop:
I have Survey.cshtml:
@page "/Survey" @model SWAT2022.Views.Home.Index1Model @{ ViewData["Title"] = "Test"; } <h1>Hello, world!</h1> <h2>The time on the server is @DateTime.Now LAT:@Model.Long LONG:@Model.Lat </h2>
and the cs Survey.cshtml.cs:
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; namespace SWAT2022.Views.Home { public class Index1Model : PageModel { public string? Lat { get; set; } public string? Long { get; set; } public void OnGet() { Lat = Request.Query["Lat"]; ; Long = Request.Query["Long"]; ; } } }
I must have a fundamental misunderstanding of RazorPages as I get this error now:Any Idea how I can integrate this Razor into my project
- Abhishek_KhatriCopper ContributorCan I get the code Then I will review and provide you a full guidance if possible
Thanks
- rajeshviCopper Contributoruse request.querystring