473,411 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

adress of project folder

I got a function that return the url of a image, the problem is that the image control on the .aspx page automaticaly adds the
adress of itself to the adress

Example:
The page http://localhost/myapp/pages/misc/index.aspx calls the function, and it returns the string "images\thumb\001.jpg"

The image control on the page will then point to the adress: http://localhost/myapp/pages/misc/images\thumb\001.jpg (wich is wrong).

The image folder is located at root of my project (myapp) so the adress should be: http://localhost/myapp/images\thumbs\001.jpg

Since the pages could be in different sub-folders at different levels under the myapp folder i can't simply add "..\..\..\" to fix
it.

Is there any function that will return the http://localhost/myapp (the rootof my project folder)?
I tried using System.AppDomain.CurrentDomain.BaseDirectory() but that will return the path as "c:\inetwww\myapp\"
Nov 18 '05 #1
3 1596
You can use Request.Url, or set an app value in Web.Config.
Brun
"Jarod_24" <ja******@hotmail.com> wrote in message
news:c7******************************@news.teranew s.com...
I got a function that return the url of a image, the problem is that the image control on the .aspx page automaticaly adds the adress of itself to the adress

Example:
The page http://localhost/myapp/pages/misc/index.aspx calls the function, and it returns the string "images\thumb\001.jpg"
The image control on the page will then point to the adress: http://localhost/myapp/pages/misc/images\thumb\001.jpg (wich is wrong).
The image folder is located at root of my project (myapp) so the adress should be: http://localhost/myapp/images\thumbs\001.jpg
Since the pages could be in different sub-folders at different levels under the myapp folder i can't simply add "..\..\..\" to fix it.

Is there any function that will return the http://localhost/myapp (the rootof my project folder)? I tried using System.AppDomain.CurrentDomain.BaseDirectory() but that will return the path as "c:\inetwww\myapp\"

Nov 18 '05 #2
Don't forget that the tilde (~) is resolved as the root of the Web. That
means you can get at the images folder from anywhere using syntax like this:

Image1.ImageUrl = "~/images/thumbs/001.jpg"

Ken
Microsoft MVP [ASP.NET]
"Jarod_24" <ja******@hotmail.com> wrote in message
news:c7******************************@news.teranew s.com...
I got a function that return the url of a image, the problem is that the
image control on the .aspx page automaticaly adds the
adress of itself to the adress

Example:
The page http://localhost/myapp/pages/misc/index.aspx calls the function,
and it returns the string "images\thumb\001.jpg"

The image control on the page will then point to the adress:
http://localhost/myapp/pages/misc/images\thumb\001.jpg (wich is wrong).

The image folder is located at root of my project (myapp) so the adress
should be: http://localhost/myapp/images\thumbs\001.jpg

Since the pages could be in different sub-folders at different levels
under the myapp folder i can't simply add "..\..\..\" to fix
it.

Is there any function that will return the http://localhost/myapp (the
rootof my project folder)?
I tried using System.AppDomain.CurrentDomain.BaseDirectory() but that will
return the path as "c:\inetwww\myapp\"


Nov 18 '05 #3
"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message news:Oc**************@TK2MSFTNGP09.phx.gbl...
Don't forget that the tilde (~) is resolved as the root of the Web. That
means you can get at the images folder from anywhere using syntax like this:

Image1.ImageUrl = "~/images/thumbs/001.jpg"

Ken
Microsoft MVP [ASP.NET]

Thanks. That worked like a charm.
Just added a "~/" at the start of the string.

"Jarod_24" <ja******@hotmail.com> wrote in message
news:c7******************************@news.teranew s.com...
I got a function that return the url of a image, the problem is that the
image control on the .aspx page automaticaly adds the
adress of itself to the adress

Example:
The page http://localhost/myapp/pages/misc/index.aspx calls the function,
and it returns the string "images\thumb\001.jpg"

The image control on the page will then point to the adress:
http://localhost/myapp/pages/misc/images\thumb\001.jpg (wich is wrong).

The image folder is located at root of my project (myapp) so the adress
should be: http://localhost/myapp/images\thumbs\001.jpg

Since the pages could be in different sub-folders at different levels
under the myapp folder i can't simply add "..\..\..\" to fix
it.

Is there any function that will return the http://localhost/myapp (the
rootof my project folder)?
I tried using System.AppDomain.CurrentDomain.BaseDirectory() but that will
return the path as "c:\inetwww\myapp\"

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: David Webb | last post by:
The problem started when the Working Folder for a project was somehow set to the folder of another project. I set the correct working folder in VSS and deleted the .vbproj files that had been...
6
by: Vagif Abilov | last post by:
We decided to adopt .NET coding guidelines posted by Brad Abrams from Microsoft: http://blogs.msdn.com/brada/archive/2005/01/26/361369.aspx Here is what Brad (and AFAIK Microsoft) suggests...
5
by: FKothe | last post by:
Hello together, the program below shows a behavior i do not understand. When compiled with the HX-UX11 c-comiler ( version B.11.11.04 ) v2.p in function test_it0 points to an invalid adress and...
8
by: Adam Clauss | last post by:
I have a folder containing many subfolders (and subfolders and....) all containing various .cs files. Is there any "easy" way to get them all added to the solution. Preferable would be that the...
0
by: Jarod_24 | last post by:
I got a function that return the url of a image, the problem is that the image control on the .aspx page automaticaly adds the adress of itself to the adress Example: The page...
3
by: Jarod_24 | last post by:
I got a function that return the url of a image, the problem is that the image control on the .aspx page automaticaly adds the adress of itself to the adress Example: The page...
4
by: Brad | last post by:
I'm not one to rant or flame....so please excuse me while I do so for this once. I've now spent a bit of time working with VS2005 beta 2 to see how it functions for web development, especially how...
8
by: vinesh | last post by:
I have sample Asp.Net Web Application project. Let me know how to keep the files related to this project (like the webform.aspx, WebForm1.aspx.vb, WebForm1.aspx.resx) in a separate folder within a...
11
by: mwebel | last post by:
Hi, i had this problem before (posted here and solved it then) now i have the same problem but more complicated and general... basically i want to store the adress of a istream in a char* among...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.