Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 13th, 2006, 04:18 PM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default Redirect all pages of my web application

Hello

Supose i want to work on my uploaded website tonight, what can i do quickly for make all page redirect to a single page saying "temporarily unavailable. We come back soon"

in another forum had said me to use global.asax

It's possible?

Any Sugestion ?

Thanks,
Max

  #2 (permalink)  
Old November 13th, 2006, 05:02 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Ya use the global.asax file, specifically the OnSessionStart event.

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
  #3 (permalink)  
Old November 13th, 2006, 05:50 PM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, but can you be more explicit ?

I wrote this code

Code:
        Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
            ' Fires when the session is started
            Response.Redirect("unavailable.aspx")
        End Sub
It worked, but only first time.

After I go to "unavailable.aspx" page if i write ".../otherpage.aspx" i will go to "otherpage.aspx"

How can i prevent this?

Thanks,
Max

  #4 (permalink)  
Old May 22nd, 2007, 02:30 PM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Any word on this? I'm trying to accomplish the same thing but it was never resolved.

  #5 (permalink)  
Old May 22nd, 2007, 03:08 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Well, here is the thing, the Session_Start event will ONLY fire one time per every session that starts, so that is why you are able to go to any other page after that.

The BeginRequest event of the global.asax file is raised EVERY time a request is made to the application so you might have some luck there.

Lastly, you could use URL rewriting so that ANY incoming URL was redirected to your system maintance page.

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
  #6 (permalink)  
Old May 22nd, 2007, 03:32 PM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

By BeginRequest I assume you mean Application_BeginRequest? I have already tried these approaches there in my global.asax, and none of them work:

Response.Redirect("page.aspx")
Server.Transfer("page.aspx")
HttpContext.Current.Response.Redirect("page.aspx")
HttpContext.Current.Server.Transfer("page.aspx")

To clarify, when I say "none of these work", I mean that there is no error occurring, but the coded action is NOT taking place. It is as if I never added the code. So I went ahead and tried them in almost every SUB available to global.asax, and again, nothing. No error and no redirect, not even the first time (with or without active sessions).

I'm not familiar with the term "URL rewriting"....


  #7 (permalink)  
Old May 22nd, 2007, 03:53 PM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Maybe my global.asax isn't firing at all? Is there any reason this would be or possibility this could happen? Maybe something in my web.config?

  #8 (permalink)  
Old May 22nd, 2007, 05:30 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

No. You Global.asax will always raise its events (as far as i know) and there is no way to turn them off. Read this about the Application Begin Request: http://msdn2.microsoft.com/en-us/library/ms227673(vs.80).aspx

URL Rewriting is employed by plenty of sights, although you may not have noticed it. For example: www.foo.com/product.aspx?id=3&cat=4 now with URL Rewriting a user may be able to type this www.foo.com/Widgets/Super-Widget/ into their address bar and actually be directed to the page product.aspx with the id and category variables still in tact.

Its transparent to the user and it makes your sites much more SEO friendly, but I digress. You achieve this by way of Regular Expressions and, it is possible, you could write an expression that would filter all requests to your website to one page.

This app is the most straight forward to get working:
http://urlrewriter.net/ and its free.

And you have this:
http://www.helicontech.com/download.htm (ISAPI Rewrite)

The latter of the 2 has 2 versions. The unpaid version can only be used within one domain, whereas the paid version can be configured to handle multiple domians. Also, because it is an ISAPI filter you have a bit of a preformance increase over URLRewriter but it is also a tad bit more complex to work with.

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
  #9 (permalink)  
Old May 23rd, 2007, 09:33 AM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Trying to get ANYTHING in global.asax to happen isn't working for me. Forget about redirection, I can't even set or increment a value for a session variable.

1) I initialize session variable and set it to 0 in Application_Start
2) Put code to increment it in both Session_Start and Application_BeginRequest
3) Code to output it onto an aspx page
4) Variable never has a value, not even 0

If I put code in the aspx page to set or increment the variable, it works fine. global.asax is not working.

Ideas anyone?

  #10 (permalink)  
Old May 23rd, 2007, 09:36 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Is your directory set up as an application in IIS?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========




Similar Threads
Thread Thread Starter Forum Replies Last Post
Display web cam in web pages peace2007 ASP.NET 2.0 Basics 1 September 17th, 2007 01:07 PM
How to redirect a web page ludigova Beginning PHP 1 September 4th, 2007 02:54 PM
redirect some pages automatically Maxxim ASP.NET 2.0 Professional 7 July 4th, 2007 08:16 AM
Web pages constructing: I-mode(mobile) pages karib Dreamweaver (all versions) 3 June 6th, 2004 09:48 AM
Printing Web Pages gaghazoul VBScript 0 February 5th, 2004 02:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.