Hi,
Where is the best place to check the session's object, if it's null, then
redirect the user to login page?
put into every page's load event?
Thanks. 5 10837
LL,
There will always be a session object available to you (or at least,
there should be). The best way to do this would be to set up the web.config
file to deny any unauthorized users. Basically, you place a <deny
users="?"> element in the <authorization> section and it will redirect
unauthorized users to the login page that you specify.
Check out the section of the .NET framework titled "Forms Authentication
Provider", located at (watch for line wrap): http://msdn.microsoft.com/library/de...onprovider.asp
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"LL" <li*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... Hi,
Where is the best place to check the session's object, if it's null, then redirect the user to login page?
put into every page's load event?
Thanks.
Thanks Nicholas.
I use "Form Auth" to login. and I still need to store some info in the
Session["xx"] for other pages. How to deal the case: if session expire.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Source Error:
Line 378: StateIndex["ON"] = 7;
Line 379:
Line 380: if (Session["Lever"] == null)
Line 381: {
Line 382: Response.Redirect("login.aspx");
Source File: c:\project\Test\admin.aspx.cs Line: 380
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:el**************@TK2MSFTNGP12.phx.gbl... LL,
There will always be a session object available to you (or at least, there should be). The best way to do this would be to set up the
web.config file to deny any unauthorized users. Basically, you place a <deny users="?"> element in the <authorization> section and it will redirect unauthorized users to the login page that you specify.
Check out the section of the .NET framework titled "Forms
Authentication Provider", located at (watch for line wrap):
http://msdn.microsoft.com/library/de...onprovider.asp Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"LL" <li*******@hotmail.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... Hi,
Where is the best place to check the session's object, if it's null,
then redirect the user to login page?
put into every page's load event?
Thanks.
Hi LL,
You should always check the session's objects for null before doing
anything with it, if it's null either the previous session expired or the
object has not been created yet.
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"LL" <li*******@hotmail.com> wrote in message
news:Oh**************@TK2MSFTNGP11.phx.gbl... Thanks Nicholas.
I use "Form Auth" to login. and I still need to store some info in the Session["xx"] for other pages. How to deal the case: if session expire.
Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 378: StateIndex["ON"] = 7; Line 379: Line 380: if (Session["Lever"] == null) Line 381: { Line 382: Response.Redirect("login.aspx");
Source File: c:\project\Test\admin.aspx.cs Line: 380 "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:el**************@TK2MSFTNGP12.phx.gbl... LL,
There will always be a session object available to you (or at least, there should be). The best way to do this would be to set up the web.config file to deny any unauthorized users. Basically, you place a <deny users="?"> element in the <authorization> section and it will redirect unauthorized users to the login page that you specify.
Check out the section of the .NET framework titled "Forms Authentication Provider", located at (watch for line wrap):
http://msdn.microsoft.com/library/de...onprovider.asp Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"LL" <li*******@hotmail.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... Hi,
Where is the best place to check the session's object, if it's null, then redirect the user to login page?
put into every page's load event?
Thanks.
Thanks Ignacio.
How to check?
Using this one:
if (Session["Lever"] == null)?
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:uA**************@TK2MSFTNGP11.phx.gbl... Hi LL,
You should always check the session's objects for null before doing anything with it, if it's null either the previous session expired or the object has not been created yet. Cheers,
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation
"LL" <li*******@hotmail.com> wrote in message news:Oh**************@TK2MSFTNGP11.phx.gbl... Thanks Nicholas.
I use "Form Auth" to login. and I still need to store some info in the Session["xx"] for other pages. How to deal the case: if session expire.
Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.
Source Error:
Line 378: StateIndex["ON"] = 7; Line 379: Line 380: if (Session["Lever"] == null) Line 381: { Line 382: Response.Redirect("login.aspx");
Source File: c:\project\Test\admin.aspx.cs Line: 380 "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:el**************@TK2MSFTNGP12.phx.gbl... LL,
There will always be a session object available to you (or at
least, there should be). The best way to do this would be to set up the web.config file to deny any unauthorized users. Basically, you place a <deny users="?"> element in the <authorization> section and it will redirect unauthorized users to the login page that you specify.
Check out the section of the .NET framework titled "Forms Authentication Provider", located at (watch for line wrap):
http://msdn.microsoft.com/library/de...onprovider.asp Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"LL" <li*******@hotmail.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... > Hi, > > Where is the best place to check the session's object, if it's null,
then > redirect the user to login page? > > put into every page's load event? > > Thanks. > >
Hi,
Yep, that will work ;)
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"LL" <li*******@hotmail.com> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl... Thanks Ignacio.
How to check? Using this one: if (Session["Lever"] == null)?
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:uA**************@TK2MSFTNGP11.phx.gbl... Hi LL,
You should always check the session's objects for null before doing anything with it, if it's null either the previous session expired or
the object has not been created yet. Cheers,
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation
"LL" <li*******@hotmail.com> wrote in message news:Oh**************@TK2MSFTNGP11.phx.gbl... Thanks Nicholas.
I use "Form Auth" to login. and I still need to store some info in the Session["xx"] for other pages. How to deal the case: if session
expire. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 378: StateIndex["ON"] = 7; Line 379: Line 380: if (Session["Lever"] == null) Line 381: { Line 382: Response.Redirect("login.aspx");
Source File: c:\project\Test\admin.aspx.cs Line: 380 "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
wrote in message news:el**************@TK2MSFTNGP12.phx.gbl... > LL, > > There will always be a session object available to you (or at least, > there should be). The best way to do this would be to set up the web.config > file to deny any unauthorized users. Basically, you place a <deny > users="?"> element in the <authorization> section and it will
redirect > unauthorized users to the login page that you specify. > > Check out the section of the .NET framework titled "Forms Authentication > Provider", located at (watch for line wrap): > >
http://msdn.microsoft.com/library/de...onprovider.asp > > Hope this helps. > > -- > - Nicholas Paldino [.NET/C# MVP] > - mv*@spam.guard.caspershouse.com > > "LL" <li*******@hotmail.com> wrote in message > news:%2****************@TK2MSFTNGP10.phx.gbl... > > Hi, > > > > Where is the best place to check the session's object, if it's
null, then > > redirect the user to login page? > > > > put into every page's load event? > > > > Thanks. > > > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tim T |
last post by:
Hi,
I have a web application that has a number of users who administer their own
data... i have several pages that check to see if a valid userID session
exists, and if not, send them to a...
|
by: lydia sista via DotNetMonster.com |
last post by:
HI all how dya check if session is null or does not exist?
I tried using
if Session("cart")= null then
...
end if
this doesn't work it says 'null' is not declared. 'null' constant is no...
|
by: rony_16 |
last post by:
hi ,
i want to override the object session in class page , because i want to
check the Session automaticly in WebForm , without writing
"if" in evry page .
i know that i need to make a new...
|
by: Kim |
last post by:
I would like to check whether the session object contains dataset before
retrieving from the data source.
If NOT CType( Session("ds"), Dataset) = "" Then
dg.DataSource= ds.Tables("dt")...
|
by: tshad |
last post by:
I got a piece of code to check if a Web page was refreshed (user pressed
refresh button).
But I can't get it to work.
The code is:
************************************************************...
| |
by: kevin bailey |
last post by:
I have a framework working where I have multiple pages each checking the
authentication status.
Unauthorised users are redirected to a login page - otherwise the requested
page is shown.
...
|
by: webrod |
last post by:
Hi all,
how can I check a user/password in a LDAP ?
I don't want to connect with this user, I would like to connect to LDAP
with a ADMIN_LOG/ADMIN_PWD, then do a query to find the user and...
|
by: seanwalsh |
last post by:
Hi
I'm new to ASP.NET (from classic ASP) and wasn't aware of the Forms Authentication security when I started working on a website. So I built a login page that stores a CustomUser object in the...
|
by: readnlearn |
last post by:
hai,
i have written this below code for displaying captcha image whenever i entered incorrect uname,password in login page.
for that i disable the controls of captcha like textbox,labels,button and...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |