473,831 Members | 2,397 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Page Redirecting

Hi,

I'm trying to do something in global.asax that I would have thought to
be quite simple. Basically, any request at all should get sent to
another page. I actually got the code below from a book. For some
reason, it's not working.

Can someone please tell me what I'm doing wrong?

Thanks in advance,
Damien

protected void Application_Beg inRequest(objec t sender,
EventArgs e)
{
// this causes a "redirect loop"
Response.Redire ct(Request.Appl icationPath + "/Forms/
LoginPage.aspx" );

// This just "doesn't work" - standard page loads.
Context.Rewrite Path(Request.Ap plicationPath + "/Forms/
LoginPage.aspx" );
}
Jun 27 '08 #1
4 2806
da**********@ya hoo.com.au wrote:
Hi,

I'm trying to do something in global.asax that I would have thought to
be quite simple. Basically, any request at all should get sent to
another page. I actually got the code below from a book. For some
reason, it's not working.

Can someone please tell me what I'm doing wrong?

Thanks in advance,
Damien

protected void Application_Beg inRequest(objec t sender,
EventArgs e)
{
// this causes a "redirect loop"
Response.Redire ct(Request.Appl icationPath + "/Forms/
LoginPage.aspx" );
You have to check if it's the login page that is requested or not. Now
you are redirecting every request, even the ones that you are causing by
redirecting to the login page.
// This just "doesn't work" - standard page loads.
Context.Rewrite Path(Request.Ap plicationPath + "/Forms/
LoginPage.aspx" );
}
--
Göran Andersson
_____
http://www.guffa.com
Jun 27 '08 #2
Your "redirect loop" is caused because you are not checking whether the
currently executing page is "LoginPage.aspx "

So even a successful redirect to LoginPage.aspx then redirects to
LoginPage.aspx, and the cycle continues.

I suggest checking the currently loaded page (Request.Url should help).

Otherwise, it might be worth looking at using a built in Authentication
provider like FormsAuthentica tion or similar to provide this redirect to
login functionality.

Good luck,
BWC

"da**********@y ahoo.com.au" wrote:
Hi,

I'm trying to do something in global.asax that I would have thought to
be quite simple. Basically, any request at all should get sent to
another page. I actually got the code below from a book. For some
reason, it's not working.

Can someone please tell me what I'm doing wrong?

Thanks in advance,
Damien

protected void Application_Beg inRequest(objec t sender,
EventArgs e)
{
// this causes a "redirect loop"
Response.Redire ct(Request.Appl icationPath + "/Forms/
LoginPage.aspx" );

// This just "doesn't work" - standard page loads.
Context.Rewrite Path(Request.Ap plicationPath + "/Forms/
LoginPage.aspx" );
}
Jun 27 '08 #3
<da**********@y ahoo.com.auwrot e in message
news:8d******** *************** ***********@s33 g2000pri.google groups.com...
Can someone please tell me what I'm doing wrong?
This has already been answered.

However, even if you check whether the current Request.Url contains
"LoginPage.aspx ", what then...?

As it stands currently, your users will never be able to proceed any further
than the login page...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #4
>As it stands currently, your users will never be able to proceed any further than the login page...

Correct. Sorry - this wasn't the best example. I'm just 'playing
around' to test the functionality.

Out of interest, I got the response.redire ct working by ommitting
calls to the login page, however, I can't get the context.rewrite to
happen. Googling around, I found a few posts of people having trouble
with it... none of them which seemed to have answers.

Thanks very much for everyone's help :-)

On Jun 24, 7:28*pm, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
<damiensaw...@y ahoo.com.auwrot e in message

news:8d******** *************** ***********@s33 g2000pri.google groups.com...
Can someone please tell me what I'm doing wrong?

This has already been answered.

However, even if you check whether the current Request.Url contains
"LoginPage.aspx ", what then...?

As it stands currently, your users will never be able to proceed any further
than the login page...

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
Jun 27 '08 #5

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

Similar topics

3
2337
by: lozd | last post by:
Would appreciate any solutions people could offer for this. Basically I wan't to use a frameset with an aspx page as the contents rather than a htm page and I'd like to be able to redirect the main page from the code behind the contents page. I want to do this to allow the use of asp "linkbuttons" instead of hyperlinks so I can do a little processing before redirecting. The main reason for this to prevent hyperlinks of pages that have...
9
1971
by: Paul | last post by:
What I am trying to do is as follows. I have a page with 3 links,that direct the user to 3 different pages when selected after login. So all link selections will first direct the user to a login page. Once the user logs in then they are directed to the appropriate link. So for all 3 links they all go to a login page, but each link must pass information to the login in page, specifically the page to go to after login takes place. -- Paul G...
1
1625
by: craigkenisston | last post by:
Hi, I'm going nuts with a supposed simple thing. I have this page : <%@ Page language="c#" Codebehind="404page.aspx.cs" AutoEventWireup="false" Inherits="mydomain._404page" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <%@ Import Namespace="System.Web" %>
4
1499
by: Greg Smalter | last post by:
Redirecting from page to page within a web project is pretty easy. However, all Redirect methods take strings as arguments, as if you mistype the string, you don't find out until run time that you are redirecting to somewhere that doesn't exist. Worse, if you do type it correctly, but then later the page name changes or the page moves, you still won't find out until run time. I have a framework that solves this problem and guarantees,...
4
2189
by: deepukutty | last post by:
HI all, I am using IE(Internet Explorer) as my default browser for asp.net application development. Today i faced a strange problem. When ever an exception occured in the page ....application is not redirecting to the default error page which will normally come. instead page is redirecting to "http://help.internet-optimizer.com/?js=1&e=ERR500&u=http%3A//localhost/buzz/WebForm1.aspx&cls=wsi25&rid=c01"
4
8762
by: shapper | last post by:
Hello, I am using the following code line in my VB code to redirect to another page inside my web site: Response.Redirect("Message.aspx") I am getting the error: The page isn't redirecting properly Firefox has detected that the server is redirecting the request for
1
1466
by: sreekeerthi | last post by:
hi friends...this is keerthi...i am doing a project where i want to redirect my page when ever the back button is clicked...for this i am using window.onbeforeunload method..and for page redirection i am using window.location and my code is as follows <html> <head> <script type="text/javascript"> var confirm = true; window.onbeforeunload = unload; function unload() { if(confirm)
1
1788
by: Itzik | last post by:
The simple situation that works: A form (ASP 2.0 Page) with Page.MaintainScrollPositionOnPostBack set to True as well as Page.EnableViewState defaults to True. As the form's data are submitted to server and page is rendered back, the form data as well as the page scroll positions are maintained. This is OK! The complicated situation: After the form's data are submitted to server the page (let's call it X) is rendered back as usual, except...
1
3268
by: kang jia | last post by:
hi when user entered particulars in signuppage and click" signup" button, i will direct them to do_signup.php. if say the NRIC is dupicate in datebase, i will redirect them back to signup page again to re-signup, however, i would like to remain all the correct infromation, and let users re-entered their NRIC. how can i do this. can i use Session, but it seems cant work. any one can help me? my code in signup page is like this: ...
0
9793
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
10208
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
7748
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
6951
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
5620
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5785
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4417
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
2
3964
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3076
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.