473,769 Members | 7,756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Virtual path isn't working in Response.Redire ct

FN
I'm using User.Identity.I sAuthenticated on all my pages (from a base class),
and redirecting to a login page if not authenticated. The problem is that
some pages are in subfolders and others are not. Such as:

www.domain.com/mustbeauth1.aspx > www.domain.com/login.aspx

www.domain.com/folder/mustbeauth2.aspx > www.domain.com/login.aspx

If I use Response.Redire ct("login.aspx" ) the first one works, but the second
doesn't. I thought I could then use Response.Redire ct ("/login.aspx") but
that causes an exception. And I don't want to hard-code the whole domain
in case this site is used on different domains. So, how can I reference
the virtual path of a file at the root level?
Nov 17 '05 #1
2 4492
FN wrote:
I'm using User.Identity.I sAuthenticated on all my pages (from a base class),
and redirecting to a login page if not authenticated. The problem is that
some pages are in subfolders and others are not. Such as:

www.domain.com/mustbeauth1.aspx > www.domain.com/login.aspx

www.domain.com/folder/mustbeauth2.aspx > www.domain.com/login.aspx

If I use Response.Redire ct("login.aspx" ) the first one works, but the second
doesn't. I thought I could then use Response.Redire ct ("/login.aspx") but
that causes an exception. And I don't want to hard-code the whole domain
in case this site is used on different domains. So, how can I reference
the virtual path of a file at the root level?

Using ~ in a .NET call to something like Response.Redire ct means the
application's root level (.NET will map it for you). So do a

Response.Redire ct("~/login.aspx")

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET

Nov 17 '05 #2
FN wrote:
I'm using User.Identity.I sAuthenticated on all my pages (from a base class),
and redirecting to a login page if not authenticated. The problem is that
some pages are in subfolders and others are not. Such as:

www.domain.com/mustbeauth1.aspx > www.domain.com/login.aspx

www.domain.com/folder/mustbeauth2.aspx > www.domain.com/login.aspx

If I use Response.Redire ct("login.aspx" ) the first one works, but the second
doesn't. I thought I could then use Response.Redire ct ("/login.aspx") but
that causes an exception. And I don't want to hard-code the whole domain
in case this site is used on different domains. So, how can I reference
the virtual path of a file at the root level?

Using ~ in a .NET call to something like Response.Redire ct means the
application's root level (.NET will map it for you). So do a

Response.Redire ct("~/login.aspx")

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET

Nov 17 '05 #3

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

Similar topics

0
367
by: FN | last post by:
I'm using User.Identity.IsAuthenticated on all my pages (from a base class), and redirecting to a login page if not authenticated. The problem is that some pages are in subfolders and others are not. Such as: www.domain.com/mustbeauth1.aspx > www.domain.com/login.aspx www.domain.com/folder/mustbeauth2.aspx > www.domain.com/login.aspx If I use Response.Redirect("login.aspx") the first one works, but the second doesn't. I thought I...
2
3338
by: Dune | last post by:
I'm trying to execute an aspx page by calling Server.Execute. The aspx page I'm trying to execute is in a different web app from the aspx page containing the Server.Execute statement. A slightly clearer explanation... Page1 exists in WebApp1. In the code-behind of Page2 in WebApp2, I have put Server.Execute("Path to Page1 in WebApp1"). When I call Server.Execute(String) using "http://localhost/WebApp1/Page1.aspx", everything works ok...
2
6063
by: Tom Wells | last post by:
I have a little file upload page that I have been able to use to successfully upload files to the C: drive of LocalHost (my machine). I need to be able to upload to a network drive from the intranet server. On the line: dirs = Directory.GetDirectories(currentDir) I get "Access to the path "\\les-net\les\Special Projects\ATSPDF" is denied." How do I get the GetDirectories command to user my user ID and password when it tries to hit the...
3
3398
by: mark.irwin | last post by:
Hello all, Have an issue where a redirect pushes data to a page with a select case which then redirects to another page. Problem is the redirect isnt working in 1 case. Code below: strURL = "" if i = 1 then strURL = "redirect.aspx?page=APIQ&parcel=" & strParcel &
5
2937
by: Stu Carter | last post by:
Hi, ENV: Windows 2003 Server SP1 (+all updates), VS 2003, .Net 1.1 SP1 We've got an ASP.Net web application using State Service. All is fine until we tried to use the app through a virtual directory with a space in it. e.g. 'http://localhost/My%20App'. The following exception is thrown: ----------
5
6948
by: mbosco51 | last post by:
Hi. I have a virtual path setup in order to give my web server access to a file on my app server. I am using the file system object to check for the existance of the file and if it exists, it has to validate the file date. The problem is I can't seem to find the file. I can successfully check for the existance of a file on the web server, but once I enter the virtual path it can't find anything. All three of these calls return...
1
3543
by: Webmills | last post by:
Has anyone come across the problem that I am experiencing? I have a master page using four or five Hyperlink controls, each with an ImageUrl. The ImageUrl is specified using a virtual directory path, such as ImageUrl = "~/Images/Main.gif". I have a child page in a sub directory, images all appear to be correct. However, if I use a Server.Transfer to transfer to a different child page in a different sub directory or at the root level,...
4
3237
by: tommaso.gastaldi | last post by:
Hi friends I was in the need to find a sort of "definitive" :) solution to transform a virtual path such as "~/MyDir/MyFile into a full web address. In particular I needed it * within web services *. I would like to be informed that the framework provides a function to do that, but for now I am missing it.
3
2046
by: Athmaus | last post by:
Hello, I have this ecom page that i am making where customers can select to choose additional licenses before they purchase. I have that part working with javascript. Problem is that when the selection is made and you hit the add but it isn't sending to the right pages (and i think i need to do it in another statemen instead of a if..then, since there will be at least 16 conditions here.
0
9579
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9414
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10032
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9977
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9848
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7391
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6661
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5432
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3947
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 we have to send another system

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.