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

  • SEARCH
  • Home
  • 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 7007729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:38:41+00:00 2026-05-27T21:38:41+00:00

I have taken over a project that has a lot of code that is

  • 0

I have taken over a project that has a lot of code that is concatenating strings to put together a url. I keep struggling to remember if each of these APIs return the “/” at the end of the base Url (either “http://www.mysite.com” or “http://www.mysite.com/”)

For example:

var baseUrl = "http://www.mySite.com/";
var controllerAndAction = "/Mycontroller/MyAction";

var fullUrl = baseUrl + controllerAndAction;

or

var baseUrl = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Content("~"));
var controllerAndAction = "Mycontroller/MyAction";

var fullUrl = baseUrl + controllerAndAction;

or

var baseUrl = Request.Url.GetLeftPart(UriPartial.Authority);
var controllerAndAction = "Mycontroller/MyAction";

var fullUrl = baseUrl + controllerAndAction;

or

var baseUrl = "http://www.mySite.com";
var controllerAndAction = "/Mycontroller/MyAction";

var fullUrl = baseUrl + controllerAndAction;

(Notice the “/”s at the end of baseUrl and at the beginning of controllerAndAction)

I am trying to figure out the cleanest way to make sure these create proper Urls that include a single “/” (not 2 or 0)

is there anything i can do to help confirm this (besides manually testing each one . .) ?

NOTE:

i need this code to work in an asp.net-mvc and a winforms project so i am trying to avoid code that is coupled to either one (to avoid referencing unnecessary libraries)

  • 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-27T21:38:42+00:00Added an answer on May 27, 2026 at 9:38 pm

    That isn’t fun. Check out Path.Combine for Urls. This method should allow you to combine base urls, paths and query strings.

    Note: The link suggests using a URI which is a base system class, available in any type of C#/VB project.

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

Sidebar

Related Questions

I have recently taken over a development project that has a Git repository linked
I have taken over a project that was build from suggestions in this Dan
I have taken over a project where HtmlDecode has been run on all data
I've taken over a project written in Perl that has a few dependencies such
I have a TFS 2010 Team Project that I've just taken over. The branching
I have taken over an existing project written beautifully in SQL with many useful
i have taken over a database that stores fitness information and we were having
I have taken over some code from a previous developer and have come across
I have a file that has over 200 lines in this format: name old_id
So I've taken over a VB.net web application project from another developer and have

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.