473,378 Members | 1,531 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,378 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 1588
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.