Hello everyone please let me know how to get the full page URL in razor page c#.
Get full URL.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Hello everyone please let me know how to get the full page URL in razor page c#.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amit MohantyRank #112 · 20K reputationPosted Jun 9, 2023, 7:27 AM EDT
@page @{ var pageUrl = HttpContext.Request.Scheme + "://" + HttpContext.Request.Host + HttpContext.Request.Path + HttpContext.Request.QueryString; } Page URL: @pageUrlBrahma Prakash ShuklaRank #633 · 3.8K reputationPosted Jun 23, 2023, 1:59 AM EDT
using Microsoft.AspNetCore.Mvc.RazorPages; public class YourPageModel : PageModel { public string FullPageUrl { get; set; } public void OnGet() { FullPageUrl = HttpContext.Request.Scheme + "://" + HttpContext.Request.Host + HttpContext.Request.Path + HttpContext.Request.QueryString; } }