473,473 Members | 1,894 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Redirection

65 New Member
Hi,

i have my app wherein i am redirecting to other pages from my code behind for eg:
Response.Redirect("\MyVirtualDirName\Admin.aspx").

However this is a bit tightly bound in the sense that if i were to change the name
of my virtual directory then the applicatio n would break.

So if there any other way to do this.. can it be done through the we.config.

Thanks
May 17 '07 #1
17 1401
jitendradotnet
6 New Member
Hi,

i have my app wherein i am redirecting to other pages from my code behind for eg:
Response.Redirect("\MyVirtualDirName\Admin.aspx").

However this is a bit tightly bound in the sense that if i were to change the name
of my virtual directory then the applicatio n would break.

So if there any other way to do this.. can it be done through the we.config.

Thanks

It should work.

Response.Redirect("~/admin.aspx");

Happy programming :)
May 17 '07 #2
Nitinkcv
65 New Member
Hi,
Ya thanks a lot.. however like i also have images whose path are being set using the virtual directory name. But if i use the ~ its not coming proper. Giving like:
images/ad.gif instead of /VirDirName/images/ad.gif works well for those files which are not inside any folders.

If some files are inside a folder and i were to give images/ad.gif then the images are not displayed properly.

Thankx.
May 17 '07 #3
jitendradotnet
6 New Member
Hi,
Ya thanks a lot.. however like i also have images whose path are being set using the virtual directory name. But if i use the ~ its not coming proper. Giving like:
images/ad.gif instead of /VirDirName/images/ad.gif works well for those files which are not inside any folders.

If some files are inside a folder and i were to give images/ad.gif then the images are not displayed properly.

Thankx.

<img src="~/images/ad.gif" />

It will work.

enjoy :)
May 17 '07 #4
Nitinkcv
65 New Member
Hi,

Please note im not geeting the oimages properly linked. If i right click on the image
and click properties im getting its path as http://localhost/MyVirDirec/~/images/ad.gif instead of
http://localhost/MyVirDirec/images/ad.gif

what could be the prob?

Thanks
May 17 '07 #5
jitendradotnet
6 New Member
Hi,

Please note im not geeting the oimages properly linked. If i right click on the image
and click properties im getting its path as http://localhost/MyVirDirec/~/images/ad.gif instead of
http://localhost/MyVirDirec/images/ad.gif

what could be the prob?

Thanks

<image src="images/ad.gif" />

Now use this only.

Probably it will work.
May 17 '07 #6
Nitinkcv
65 New Member
Hi,

no that wont work coz it takes it to the directory above.. like the image link is
localhost/images instaed of localhost/VirDirecName/images.
May 17 '07 #7
leela mn
43 New Member
try ths
../images/ad.gif
May 17 '07 #8
Nitinkcv
65 New Member
Hi,

sorry even thats not working for the files which are inside the folder.. its working for for the ones which are in the folder where the images folder is..

Thanks
May 17 '07 #9
leela mn
43 New Member
first u freeze the folder in which all u r images to be there
then u can use ../images/filename
May 18 '07 #10
Nitinkcv
65 New Member
Hi,

i wuite didnt undrstand what u meant by freeze the folder.. could u explain a bit more plz?

Thanks
May 18 '07 #11
leela mn
43 New Member
i mean to say place all your images in one folder.
May 18 '07 #12
Nitinkcv
65 New Member
hi,

alll my images are in one folder.. i think u didnt understand me..
The thing is all the pages which are in the same directory as tyhe images folder are properly linking with the images.. but i have the pages inside the admin folder are not..
Heirarchy:
Main folder: contains page1.aspx, page2.aspx, images folder and admin folder
admin folder: contains admin1.aspx, admin2 .aspx.

Problem: page1.aspx, page2.aspx are linking properly with the images inside the images folder . but the admin1.aspx, admin2 .aspx. are not linking properly with the images inside the images folder.

Hope this is clear.
Thanks
May 18 '07 #13
Frinavale
9,735 Recognized Expert Moderator Expert
hi,

alll my images are in one folder.. i think u didnt understand me..
The thing is all the pages which are in the same directory as tyhe images folder are properly linking with the images.. but i have the pages inside the admin folder are not..
Heirarchy:
Main folder: contains page1.aspx, page2.aspx, images folder and admin folder
admin folder: contains admin1.aspx, admin2 .aspx.

Problem: page1.aspx, page2.aspx are linking properly with the images inside the images folder . but the admin1.aspx, admin2 .aspx. are not linking properly with the images inside the images folder.

Hope this is clear.
Thanks
If the user is visiting your site they are at

~/webAppLocation/adminFolder/admin1.aspx.

To reach the images properly from admin1.aspx you'll have to use:

../images/imageName.jpg

This will bring you up one directory from the admin folder and then into the images folder.
May 18 '07 #14
Nitinkcv
65 New Member
Expand|Select|Wrap|Line Numbers
  1. If the user is visiting your site they are at
  2.  
  3. ~/webAppLocation/adminFolder/admin1.aspx.
  4.  
  5. To reach the images properly from admin1.aspx you'll have to use:
  6.  
  7. ../images/imageName.jpg
  8.  
  9. This will bring you up one directory from the admin folder and then into the images folder.
Hi,

im using a common page which has images and their links. This page is used as the reference fo all other pages to display the images the images. ie page1.aspx ans well as admin1.aspx are referencing this common page to get the images.

So if in the src tag of the images i were to give ../images/imageName.jpg then would it properly link with both the page1.aspx and asmin1.aspx. Since the ../ would take it to one directory up, would it link with page1.aspx. I think it would link with admin1.aspx.

Thanks
May 19 '07 #15
Abdul Haque
17 New Member
use this syntax
<img src="/images/ad.gif" >

i.e. a root relative path, instead of 'document relative' or 'absolute path'
May 22 '07 #16
Nitinkcv
65 New Member
use this syntax
<img src="/images/ad.gif" >

i.e. a root relative path, instead of 'document relative' or 'absolute path'
Hi,
no this too doesnt work
May 23 '07 #17
Plater
7,872 Recognized Expert Expert
Funny, I do the same thing.
I have a website at
http://mywebsite/mywebmodule/default.aspx
which has folders:
admin/ (http://mywebsite/mywebmodule/admin/default.aspx)
user/ (http://mywebsite/mywebmodule/user/default.aspx)
images/ (where all my pictures sit)

I use this with no problem in all of my pages (regardles of the folder)
[html]
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/rxbanner.JPG" AlternateText="my alt text" />
[/html]

With that being said though, the ~ only applies when used in the .aspx page (the designer page) and not in C# code.
The ~ is a pre-compiler command that will get replaced at runtime with the url. It does not apply to the backend. (That means you cannot use it in Response.Redirect() calls)
I recomend you make some kinda global method or something that will return the begining url you want. Inside that method you can either "hard-code" the /MyVirtualDirectory/ or you can write up code devised to extract the virtual directory based upon the Request.Url
May 23 '07 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues...
52
by: Gerard M Foley | last post by:
Can one write a webpage which is not displayed but which simply redirects the user to another page without any action by the user? Sorry if this is simple, but I am sometimes simple myself. ...
15
by: Taki Jeden | last post by:
Hello everybody Does anybody know why w3c validator can not get pages that use 404 htaccess redirection? I set up two web sites so that clients request non-existent urls, but htaccess redirects...
2
by: Nadav | last post by:
Hi, Introduction: *************** I am trying to redirect stdout to a RichEdit control, this is done by initiating a StringWriter, associated it with a StringBuilder and setting the...
0
by: Dimitrios Mpougas | last post by:
Hello, I have two asp.net pages. The first is a page (main.aspx) wich has four links on it. The href value of each link is: href="view.aspx?id=1" traget="_blank" href="view.aspx?id=2"...
8
by: Luciano A. Ferrer | last post by:
Hi! I was following the http://www.seomoz.org/articles/301-redirects.php article, trying to do that with one of my test sites I added this to the .htaccess file: RewriteEngine On RewriteCond...
13
by: souissipro | last post by:
Hi, I have written a C program that does some of the functionalities mentionned in my previous topic posted some days ago. This shell should: 1- execute input commands from standard input,...
1
by: comp.lang.php | last post by:
require_once("/users/ppowell/web/php_global_vars.php"); if ($_GET) { // INITIALIZE VARS $fileID = @fopen("$userPath/xml/redirect.xml", 'r'); $stuff = @fread($fileID,...
4
by: psual | last post by:
hi newbie in web design I got some issue concerning a secure redirection between 2 pages let say I have a page with a grid (the 'master' page) in this grid I can select a record, get its pk...
13
by: Massimo Fabbri | last post by:
Maybe it's a little OT, but I'll give it try anyway.... I was asked to maintain and further develop an already existing small company's web site. I know the golden rule of "eternal" URIs, but...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.