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 8616287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:34:55+00:00 2026-06-12T05:34:55+00:00

OK most of us develop and test the Asp.NET Web Applications in our localhost

  • 0

OK most of us develop and test the Asp.NET Web Applications in our localhost before publishing them to the production server. But to me, localhost is a pain sometimes since I cannot get the absolute path properly. Because lets say my app is located in http://localhost/MyApp/ I cannot properly get the host. I can get it with a couple of code but I like to make it more generic so whenever some other developer puts the same application in another location such as http://localhost/TheirApp, then it should work fine.

Sample Problem:

Whenever I use absolute path like this /aboutus.aspx, it causes this http://localhost/aboutus.aspx and omits MyApp. If I use relative path, then it becomes http://localhost/MyApp/IamHere.aspx/aboutus.aspx which is rather disturbing.

So if Request.Url.Authority or Request.Url.Host would return http://localhost/MyApp then we could append our url using these and find a nice solution.

An Alternative Solution:

I could do this:

if(Request.Url.Host.StartsWith("localhost"))
{
    string[] segments = Request.Url.AbsolutePath.Split("/");
    var localHost = Request.Url.Authority + "/" + segments[0];
}

then I can use localHost variable and append my path to it.

But I like to learn how you guys are dealing with such problem?

Thanks,

  • 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-06-12T05:34:56+00:00Added an answer on June 12, 2026 at 5:34 am

    I’m not quite sure of what you are trying to achieve, but you can use the tilde (~) to refer to the web application’s root and that should solve your problem.

    string url = ResolveUrl("~/aboutus.apsx");
    

    The ASP.NET application will figure out by itself if ~ should be localhost, localhost:34534, someserver.net/Deep/Path or anything else.

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

Sidebar

Related Questions

What is the most usual way to develop views in asp.net mvc? Should I
We develop a fair number of web-based applications, most of which are hosted on
Most of the ASP.NET MVC paging solutions I have found by googling look like
We develop for web. For some reason our design team hates [the look of]
I am trying to develop a query that will delete all but the most
I develop websites and sometimes clients already have websites but need them totally revamped
What are the most common or vicious mistakes when experienced C++ programmers develop in
Most of us write conditionals like: if (resultIndex == 0) ...but occaisionally I come
I develop in a proprietary script language with very resumed code in which most
I'm going to develop a web application based on mathematics. It's going to provide

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.