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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:50:50+00:00 2026-05-27T16:50:50+00:00

I have an ASP.NET Razor website that is working properly when I test locally

  • 0

I have an ASP.NET Razor website that is working properly when I test locally (via WebMatrix IIS).

When I put it "online" on my server, the website is not at the root of the site itself. For example:

http://intranet.mycompany.com/inform

That’s basically the "root" of my folder structure, so all my folders starts from there (CSS files, default.cshtml… and so on)

My "_PageStart.cshtml" sees it properly, because when I access my site from the link http://intranet.mycompany.com/inform, it gives me the Layout I have configured in _PageStart.cshtml (and it really shows the layout + the rendered default.cshtml).

BUT nothing else is getting the proper path, for example:

<img src="~/images/logos/hdr.png" />

The img holder is there I can see it, but it shows that the link is broken. When I right-click the img holder and select properties to see where the files should be, it shows me:

http://intranet.mycompany.com/images/logos/hdr.png

So it’s going to the "full" root, not the site relative root, which would be:

http://intranet.mycompany.com/inform/images/logos/hdr.png

How can I fix that?

  • 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-27T16:50:50+00:00Added an answer on May 27, 2026 at 4:50 pm

    You have to use relative paths all over your app:

    ~ won’t work within static HTML code.

    You can write

    <img src="@Url.Content("~/images/logos/hdr.png")" />
    

    or

    <img src="../images/logos/hdr.png" />
    

    The first approach is good for layout files where your relative path might be changing when you have different length routing URLs.

    Regarding to your question about normal links, when linking to another page in your app you don’t specify the view file as the target but the action which renders a view as the result. For that you use the HtmlHelper ActionLink:

    @Html.ActionLink("Linktext", "YourController", "YourAction")
    

    That generates the right URL for you automatically:

    <a href="YourController/YourAction">Linktext</a>
    

    If you are not using MVC, you have to generate your links yourself. You have to use relative paths, too. Don’t start any link with the / character!

    <a href="linkOnSameLevel.cshtml">Link</a>
    <a href="../linkOnParentLevel.cshtml">Link</a>
    <a href="subFolder/linkOnOneLevelDown.cshtml">Link</a>
    

    When using Layout pages you can use the Href extension method to generate a relative URL:

    <link href="@Href("~/style.css")" ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on asp.net MVC 3 application. I have created a Razor view
I have an ASP.NET MVC website which has a particular javascript file that needs
With ASP.NET MVC3 (Razor) I have a simple page that loads a jQuery UI
i have some problem here with Edit Data Using ASP.NET Razor in WebMatrix i
i have some problem here with Edit Data Using ASP.NET Razor in WebMatrix i
I have built an ASP.NET MVC 3 web application (with exlusively Razor/cshtml pages) that
I have a asp.net website in the umbraco cms, there I can use razor
I am working on a website in ASP .NET MVC 3 using Razor and
I have an ASP.NET MVC 3 view using Razor and Knockout.js that is not
I have an ASP.NET MVC 3 page ( Razor ) that consists of a

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.