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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:41:43+00:00 2026-05-23T00:41:43+00:00

Let say I have a web application : www.mymvcsite.com/MyVirtualDirectory/Controller/Action In my view I have

  • 0

Let say I have a web application :

http://www.mymvcsite.com/MyVirtualDirectory/Controller/Action

In my view I have a <a href="/FolderA/myfile.pdf">. Problem is the entire Html is coming from from a database! Aha! You thought this was as easy as @Url.Content()… well that doesn’t work cause the html is dynamic in fact I have no idea that there is even link element in the markup I’m blindly outputting it to the view.

So what do I need to put in the href in order for it to resolve the Url properly.

Ie. “myfile.pdf” is located at…
http://www.mymvcsite.com/MyVirtualDirectory/FolderA/myfile.pdf

BUT for some reason in the browser the url ends up being
“www.mymvcsite.com/FolderA/myfile.pdf”

Note that the “MyVirtualDirectory” is missing! I even tried adding a “~” to the Url but that doesn’t work either.

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-05-23T00:41:44+00:00Added an answer on May 23, 2026 at 12:41 am

    You need to store the relative url in a hidden field:

    <input id='hidPartialUrl' type='hidden' value='<%:ResolveUrl("~/") %>'/>
    

    All links should be relative to the root of the site and have a common class name:

    <a href='/FolderA/myfile.pdf' class='fixThisLink'>PDF</a> 
    

    Then when you load it into the page you do:

    var hiddenHref = document.getElementById('hidPartialUrl').href;
    var links = document.getElementsByClassName('fixThisLink'); 
    for(var i = 0; i < links.length; i++) {
        links[i].href = hiddenHref + links[i].href;
    }
    

    Set the href property on each one returned to include the first part of your url. I would store the first part of your url in a hidden field.

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

Sidebar

Related Questions

I have Symfony 1.4 web-application. Let's say my app is hosted on example.com and
Let's say we have a grails web application exposing several resources. tags urls users
Let say, I have a web application that allows users to upload images and
Let's say I have a Tomcat and a web application on it with index.html
I have a web application containing two web services, let's say PublicHello.asmx and RestrictedHello.asmx
In our web application, we have multiple small applications availables. Let us say A,B,C.
Let say I have two methods in MVC 4 Web API controller: public IQueryable<A>
Let's say I have an web CMS type application, and an EDM model with
Let's say I have an ASP.NET web application. I create an aspx page that
Let's say I have a Spring MVC web application and it allows users to

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.