Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3496754
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:17:16+00:00 2026-05-18T12:17:16+00:00

Scenario is I have a application relative url like ~/path/to/page.aspx?query=string. I need to programatically

  • 0

Scenario is I have a application relative url like “~/path/to/page.aspx?query=string”. I need to programatically create a web request to that page and currently using WebRequest.Create. The problem is WebRequest.Create requires a fully qualified url including the protocol/domain/port etc.

I have access to the current Request.Url object but there doesn’t seem to be an easy way to get just the base url keeping the protocol (HTTP vs HTTPS) as well as any port numbers as well as the path to the application.

I mean all the info there, so if need be I could just take all the parts and combine them but it seems like it might be error prone and it would be great to have something built-in that’s well tested to do the job. Page.ResolveUrl gets me almost there, but it’s missing the protocol and the domain/port.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T12:17:16+00:00Added an answer on May 18, 2026 at 12:17 pm

    Try System.Web.VirtualPathUtility.ToAbsolute(). I’ve used that (albeit in VB.NET, but I’m sure there’s a C# equivalent) with a great deal of success. It can even translate just a base virtual path (i.e. System.Web.VirtualPathUtility.ToAbsolute("~") will turn into the base url of your app).

    EDIT

    How about Request.Url.GetLeftPart(UriPartial.Authority)? That should get the Scheme and Authority parts of the Url (which I believe are the protocol and domain you refer to). Here’s the MSDN doc: http://msdn.microsoft.com/en-us/library/system.uri.getleftpart.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a scenario where users of my ASP.NET web application submit testimonials consisting
Scenario I have an application using asp.net Master Pages in which I would like
Here's the scenario: You have an ASP.Net application supported by a Microsoft SQL Server
I have this typical scenario. I have a smartclient application built on .net 2.0
I am using SVNKit in my application. I have a scenario wherein certain files
Scenario: I have an application that pulls data from a SQL database as well
I have a simple ASP.NET MVC web application that uses NHibernate with FluentNHibernate's auto
I have a scenario in my application, by saving a text of length 20000
The scenario is this We have two applications A and B, both which are
Scenario: Let's say I have four very similar applications (i.e. most of the functionality

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.