Display page based on the login user

G

Guest

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
 
G

Guest

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
 
G

Guest

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 said:
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 said:
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
 
P

parshuram

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 said:
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 said:
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 said:
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
 
G

Guest

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 said:
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 said:
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 said:
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


:

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
 
G

Guest

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 said:
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 said:
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 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top