Hi All,
I m working on a project that has different sub-projects. I would like to include a link to a file that is placed in another folder. For ex. My file whose path is ProjB/FolderB/FileB.asp --I want to write a line of code that will enable me to link to a file whose path is ProjA/FolderA/FileA.asp.
Can I achieve this using the navigateURL command?How?
Thanks in advance.

Dani AI

Generated

Good call by and well done for getting the relative link to work. A few clarifications that often help later when the projects move to IIS or another server:

NavigateUrl is a property on server controls (for example the WebForms HyperLink control) — not a separate command. It accepts absolute URLs, app‑relative URLs (the "~" shorthand) or plain relative paths. Use ResolveUrl (or VirtualPathUtility.ToAbsolute) when you build app‑relative links in code, and build a full host URL when you must link from one IIS application to another.

// same application: app-relative resolved at runtime
myHyperLink.NavigateUrl = ResolveUrl("~/Shared/Docs/Guide.aspx");

// different app/site: build a full absolute URL
var host = Request.Url.GetLeftPart(UriPartial.Authority); // https://example.com
myHyperLink.NavigateUrl = host + "/OtherApp/Public/File.aspx";

If the two sub-projects are separate IIS applications, the "~" trick only resolves inside a single application. Options there are: use absolute URLs, create a virtual directory/application so both live under the same site root, or host shared assets from a single web root (or CDN). For IIS virtual directories see the Microsoft doc on creating a virtual directory or application.

Quick troubleshooting checklist:

  • Inspect the rendered HTML (View Source) and try the URL directly in the browser.
  • Use F12/network to confirm 404/401 vs redirect problems.
  • Ensure the target file is deployed and served by IIS (correct MIME/handler).
  • Avoid embedding server file system paths (C:...) in client links.

References: HyperLink.NavigateUrl docs, Control.ResolveUrl docs, .

Recommended Answers

All 2 Replies

Hi All,
I m working on a project that has different sub-projects. I would like to include a link to a file that is placed in another folder. For ex. My file whose path is ProjB/FolderB/FileB.asp --I want to write a line of code that will enable me to link to a file whose path is ProjA/FolderA/FileA.asp.
Can I achieve this using the navigateURL command?How?
Thanks in advance.

Hi,

I guess you have two options, make an Absolute Path or a Relative Path

In the absolute path, you have to put the entire URL on the link, like,

In the relative path, you have make a "navigation" through the folders before you can reach the file, like, if you are in ProjB/FolderB/FileB.asp and you have to reach ProjA/FolderA/FileA.asp (assuming that both are in the same server) you have to do a "../../ProjA/FolderA/FileA.asp"

Try this and post back... good luck!

hey thankz.. it really helped.. i used the relative path method..it works!!
Thnx once again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.