?
Solved

How to get server name dynamicly in ASP.NET

Posted on 2003-02-25
6
Medium Priority
?
1,028 Views
Last Modified: 2012-06-27
Hi, I have a web application built on ASP.NET (VB). The application runs under one virtual directory says "App", but when running, sometimes, it needs to display some JPG images to clients which are in the other Virtual directory, says "Image".

What i am doing now is to hard code the server name in string, like "http://myhost/Image/1.jpg" this works fine now, but i need to trans the application to other server, thus will cause me problem on displaying those images.

So, is there a way to get server name dynamicly or displaying those images in another virtual directory? Thanks a lot.

By the way, those images cant be put under the same virtual directory "App", or even App/image/.

thanks

--Eric
0
Comment
Question by:sunyuchen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 23

Accepted Solution

by:
naveenkohli earned 200 total points
ID: 8023180
It is always good idea to use relative URL and not hard coded absolute URL. HEre is what you can do..

MyImage.ImageUrl = "~/Image/1.jpg"
0
 
LVL 20

Assisted Solution

by:Silvers5
Silvers5 earned 200 total points
ID: 8023350
"http://" & request.servervariables("HTTP_HOST") & "/Image/1.jpg"

do some research on servervariables.. the have lots of useful ones..
0
 

Expert Comment

by:ragural
ID: 8023836
"http://" & Request.Url.Host.ToString() & "/Image/1.jpg";
rgds
Ural
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9649848
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Split between naveenkohli and Silvers5

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheLearnedOne
EE Cleanup Volunteer
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question