473,413 Members | 2,066 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Display page based on the login user

Hello,

I have a strange problem. I want to check the privilege of the login user
on each page and allow to display if has suff. priv. I am storing the
privilege is session variable.
I am checking on the page_load event like
if session("uid")="" then
response.redirect("loginverify.aspx?er=nlog")
elseif session("priv")<>0 then
response.redirect("loginverify.aspx?er=nsad")
end if

first time it is checking OK. When i modify code in VS.NET and rebuild the
project and refresh this page its automatically redirecting to
loginverify.aspx?er=nlog(first condition) eventhough the time b/w login and
modify and refresh is 2 mts.Actually the session timeout is 20 mts lah.

Why its like this? And, i declared session("priv")=0
But when i check on the page i need to check with
if session("priv")="0"
why?

Thanx in advance
Nov 19 '05 #1
5 2256
Rak
Rajani,
when you modify a page (recompile the source), asp.net will clear the
temporay files and reset the session variables on the next request for that
page. This could be the reason for the redirection.
For the second issue (comparing session variables), Session variables are
objects. so you will have to type cast it to integer before comparing.

if(Session["priv"] != null && (int)Session["priv"] == 0) {... }

Hope this helps

Rak
"Rajani" wrote:
Hello,

I have a strange problem. I want to check the privilege of the login user
on each page and allow to display if has suff. priv. I am storing the
privilege is session variable.
I am checking on the page_load event like
if session("uid")="" then
response.redirect("loginverify.aspx?er=nlog")
elseif session("priv")<>0 then
response.redirect("loginverify.aspx?er=nsad")
end if

first time it is checking OK. When i modify code in VS.NET and rebuild the
project and refresh this page its automatically redirecting to
loginverify.aspx?er=nlog(first condition) eventhough the time b/w login and
modify and refresh is 2 mts.Actually the session timeout is 20 mts lah.

Why its like this? And, i declared session("priv")=0
But when i check on the page i need to check with
if session("priv")="0"
why?

Thanx in advance

Nov 19 '05 #2
Hello,
Tx for u r reply. I understand it. But one more problem.
How can i include files.
I have pages with different links. Based on the login user priv i need to
include that page.
In classic ASP i did like
<%
if session("priv")=0 then
%>
<!-- #include FILE="myhomesa.html" -->
<%
end if
%>

How can i do here.
I tried, convert.toint32(session("priv"))=0 then
<!-- #include FILE="myhomesa.html" -->
end if

convert is not allowed in <% %>

Thanx
"Rak" wrote:
Rajani,
when you modify a page (recompile the source), asp.net will clear the
temporay files and reset the session variables on the next request for that
page. This could be the reason for the redirection.
For the second issue (comparing session variables), Session variables are
objects. so you will have to type cast it to integer before comparing.

if(Session["priv"] != null && (int)Session["priv"] == 0) {... }

Hope this helps

Rak
"Rajani" wrote:
Hello,

I have a strange problem. I want to check the privilege of the login user
on each page and allow to display if has suff. priv. I am storing the
privilege is session variable.
I am checking on the page_load event like
if session("uid")="" then
response.redirect("loginverify.aspx?er=nlog")
elseif session("priv")<>0 then
response.redirect("loginverify.aspx?er=nsad")
end if

first time it is checking OK. When i modify code in VS.NET and rebuild the
project and refresh this page its automatically redirecting to
loginverify.aspx?er=nlog(first condition) eventhough the time b/w login and
modify and refresh is 2 mts.Actually the session timeout is 20 mts lah.

Why its like this? And, i declared session("priv")=0
But when i check on the page i need to check with
if session("priv")="0"
why?

Thanx in advance

Nov 19 '05 #3
instead of using include directives u shud use user controls. U cud
dynamically add user controls to the page and put the check as u r doing
with Sessions right now.

HTH
"Rajani" <Ra****@discussions.microsoft.com> wrote in message
news:1B**********************************@microsof t.com...
Hello,
Tx for u r reply. I understand it. But one more problem.
How can i include files.
I have pages with different links. Based on the login user priv i need to
include that page.
In classic ASP i did like
<%
if session("priv")=0 then
%>
<!-- #include FILE="myhomesa.html" -->
<%
end if
%>

How can i do here.
I tried, convert.toint32(session("priv"))=0 then
<!-- #include FILE="myhomesa.html" -->
end if

convert is not allowed in <% %>

Thanx
"Rak" wrote:
Rajani,
when you modify a page (recompile the source), asp.net will clear the temporay files and reset the session variables on the next request for that page. This could be the reason for the redirection.
For the second issue (comparing session variables), Session variables are objects. so you will have to type cast it to integer before comparing.

if(Session["priv"] != null && (int)Session["priv"] == 0) {... }

Hope this helps

Rak
"Rajani" wrote:
Hello,

I have a strange problem. I want to check the privilege of the login user on each page and allow to display if has suff. priv. I am storing the
privilege is session variable.
I am checking on the page_load event like
if session("uid")="" then
response.redirect("loginverify.aspx?er=nlog")
elseif session("priv")<>0 then
response.redirect("loginverify.aspx?er=nsad")
end if

first time it is checking OK. When i modify code in VS.NET and rebuild the project and refresh this page its automatically redirecting to
loginverify.aspx?er=nlog(first condition) eventhough the time b/w login and modify and refresh is 2 mts.Actually the session timeout is 20 mts lah.
Why its like this? And, i declared session("priv")=0
But when i check on the page i need to check with
if session("priv")="0"
why?

Thanx in advance

Nov 19 '05 #4
Hello,

Can u make a bit clear? I am very new to ASP.NET
How to check with user controls?
I have a template in myhome.aspx
Whe the user is logged in redirects to this page and check for privilege and
includes corr links page.
How can i do this with user control. Can u give me the sample code?

"parshuram" wrote:
instead of using include directives u shud use user controls. U cud
dynamically add user controls to the page and put the check as u r doing
with Sessions right now.

HTH
"Rajani" <Ra****@discussions.microsoft.com> wrote in message
news:1B**********************************@microsof t.com...
Hello,
Tx for u r reply. I understand it. But one more problem.
How can i include files.
I have pages with different links. Based on the login user priv i need to
include that page.
In classic ASP i did like
<%
if session("priv")=0 then
%>
<!-- #include FILE="myhomesa.html" -->
<%
end if
%>

How can i do here.
I tried, convert.toint32(session("priv"))=0 then
<!-- #include FILE="myhomesa.html" -->
end if

convert is not allowed in <% %>

Thanx
"Rak" wrote:
Rajani,
when you modify a page (recompile the source), asp.net will clear the temporay files and reset the session variables on the next request for that page. This could be the reason for the redirection.
For the second issue (comparing session variables), Session variables are objects. so you will have to type cast it to integer before comparing.

if(Session["priv"] != null && (int)Session["priv"] == 0) {... }

Hope this helps

Rak
"Rajani" wrote:

> Hello,
>
> I have a strange problem. I want to check the privilege of the login user > on each page and allow to display if has suff. priv. I am storing the
> privilege is session variable.
> I am checking on the page_load event like
> if session("uid")="" then
> response.redirect("loginverify.aspx?er=nlog")
> elseif session("priv")<>0 then
> response.redirect("loginverify.aspx?er=nsad")
> end if
>
> first time it is checking OK. When i modify code in VS.NET and rebuild the > project and refresh this page its automatically redirecting to
> loginverify.aspx?er=nlog(first condition) eventhough the time b/w login and > modify and refresh is 2 mts.Actually the session timeout is 20 mts lah. >
> Why its like this? And, i declared session("priv")=0
> But when i check on the page i need to check with
> if session("priv")="0"
> why?
>
> Thanx in advance


Nov 19 '05 #5
Rak
Rajani,
In ASP.NET we generally dont use the include directives. You could organize
these common functionalities into user controls and load the dynamically in
your page.

There are lots of articles on creating and loading usercontrols. This is one
I found.
http://www.15seconds.com/issue/020319.htm

So in your pageload event of your page you will have something like

MyUsercontrol userControl = new MyUserControl();
if(Session["priv"] != null && (int)Session["priv"] == 0)
placeHolder1.Controls.Add(userControl);

sorry im not good at vb.

rgds,
Rakesh

"Rajani" wrote:
Hello,
Tx for u r reply. I understand it. But one more problem.
How can i include files.
I have pages with different links. Based on the login user priv i need to
include that page.
In classic ASP i did like
<%
if session("priv")=0 then
%>
<!-- #include FILE="myhomesa.html" -->
<%
end if
%>

How can i do here.
I tried, convert.toint32(session("priv"))=0 then
<!-- #include FILE="myhomesa.html" -->
end if

convert is not allowed in <% %>

Thanx
"Rak" wrote:
Rajani,
when you modify a page (recompile the source), asp.net will clear the
temporay files and reset the session variables on the next request for that
page. This could be the reason for the redirection.
For the second issue (comparing session variables), Session variables are
objects. so you will have to type cast it to integer before comparing.

if(Session["priv"] != null && (int)Session["priv"] == 0) {... }

Hope this helps

Rak
"Rajani" wrote:
Hello,

I have a strange problem. I want to check the privilege of the login user
on each page and allow to display if has suff. priv. I am storing the
privilege is session variable.
I am checking on the page_load event like
if session("uid")="" then
response.redirect("loginverify.aspx?er=nlog")
elseif session("priv")<>0 then
response.redirect("loginverify.aspx?er=nsad")
end if

first time it is checking OK. When i modify code in VS.NET and rebuild the
project and refresh this page its automatically redirecting to
loginverify.aspx?er=nlog(first condition) eventhough the time b/w login and
modify and refresh is 2 mts.Actually the session timeout is 20 mts lah.

Why its like this? And, i declared session("priv")=0
But when i check on the page i need to check with
if session("priv")="0"
why?

Thanx in advance

Nov 19 '05 #6

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

Similar topics

13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
8
by: Judy Ward | last post by:
I have an index.aspx with frames. The top frame has a navigation bar with a "Login" hyperlink. If the user has already logged in I want this link to change to "Logout". I am using forms-based...
3
by: | last post by:
One thing I did a lot of in Classic ASP involved showing page elements conditionally based on whether a user was logged in or not. Logged in users or "superusers" would get more content and/or more...
1
by: leovega | last post by:
Hello, My aplication starts with a simple login window (login_page.aspx). Once the login/password is validated I redirect to an html which contains 3 frames. (mywebsite.html) The web site I...
5
by: David Thielen | last post by:
Hi; Ok, I will be the first to agree that this should be impossible - except we are able to keep repeating it. Our login page - which has moderately complex html and uses <LayoutTemplate> to...
13
JodiPhillips
by: JodiPhillips | last post by:
G'day, I have a silly and simple problem that I need some guidance with. Due to the way our network is set up, I am unable to use the group permissions for Access and have had to implement log...
7
by: Jonathan Wood | last post by:
My site requires all users to log on. Depending on the user's role, they will have access to a certain set of pages. I implemented this by redirecting the user to the appropriate home page in...
7
by: srinathpandit | last post by:
Hi I have one requirement that, Based on the User ID the content should display on the page. How can we do that, I don't have much knowledge on javascript but I tried its not working. Please help...
1
by: soni2926 | last post by:
hi, we're building a site which will have common pages for different users, but certain sections will show different content based on the membership of the logged in user, like admin, manager,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...
0
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...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.