Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C# - Cancel unload of a page in ASP.NET

Posted on 2013-11-05
5
Medium Priority
?
527 Views
Last Modified: 2014-02-04
How can I cancel an unload of a page?
0
Comment
Question by:CipherIS
[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
  • 2
5 Comments
 
LVL 30

Expert Comment

by:Alexandre Simões
ID: 39626593
Refering to the page lifecycle in ASP.net, page unload is the last thing that happens... page is fully rendered, no modifications are possible mainly because everything is already sent to the client.
Page objects are still available but marked to be disposed.

So what exactly do you want to cancel?
0
 
LVL 1

Author Comment

by:CipherIS
ID: 39627734
I need to check hte value of a viewstate and depending on the viewstate value the user will be allowed to continue or must stay on that page.

I put response.redirect on the page.unload but that caused an error.
0
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 1500 total points
ID: 39633030
I put response.redirect on the page.unload but that caused an error.
As I told you before, and you can check on the ASP.net request lifecycle, there's nothing you can do on page.unload...

If you try to do a page.redirect on page.unload this means you're trying to redirect after the page is already been sent to the client!

Can't you just do this on Page.Load?
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

618 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