Showing posts with label variables. Show all posts
Showing posts with label variables. Show all posts

Saturday, March 24, 2012

this trouble me a long time :(

Hi,

I developed some applications in asp & asp.net and running together under iis5.
I found they have own set of variables each of them, that is to say, they cannot pass a variable between the asp and asp.net applications.

i.e.
I set a session in asp: session("counter") = 100
I cannot get its value in asp.net by: session["counter"] because "counter" not be given.

I do wanna exchange information between them, but how can I? Any good idea?

thanksSession sharing between ASP and ASP.NET

Remember, Google knows all.

Thursday, March 22, 2012

Thoughts about using Session variables for login security?

I am creating a simple website with a login page and some "admin only"
pages.
In my login page's submit button I just say if the "password is correct"
then...
session("IsAdmin") = True
In my admin only pages I check if session("IsAdmin") = True
If it's NOT then I redirect them to the login.aspx page.
Is this solution pretty solid, or is it easy to hack? I keep the password
in the web.config appsettings section so it's easy to change.
I know I could use Membership stuff, but I'm just doing a simple, quick
website.
Your thoughts are appreciated!Hello Bobby,

> I am creating a simple website with a login page and some "admin only"
> pages.
> In my login page's submit button I just say if the "password is
> correct"
> then...
> session("IsAdmin") = True
> In my admin only pages I check if session("IsAdmin") = True If it's
> NOT then I redirect them to the login.aspx page.
> Is this solution pretty solid, or is it easy to hack? I keep the
> password in the web.config appsettings section so it's easy to change.
> I know I could use Membership stuff, but I'm just doing a simple,
> quick website.
Membership is there, membership is quick and membership works out of the
box from the web.config if you need it to.
My experience is that this quick and simple website will run for the coming
20 years and that every time you need to change somthing you hoped you did
it the right way first time round...
--
Jesse Houwing
jesse.houwing at sogeti.nl
I've done the same thing in the past. There is one and only quesion
you need to ask: "is this doing what I need it to?" From your post the
answer is "yes," so you're good. But I see you're asking "is it easy
to hack?"
And the answer is a resounding "no." Session variables are stored in
the server's memory. In order to access them a hacker would need to
hack the server itself and gain access to it's memory. If that
happens, having them view your session variables would be the very
least of your concerns.
On Mar 5, 2:33=A0pm, "Bobby Edward" <t...@.test.com> wrote:
> I am creating a simple website with a login page and some "admin only"
> pages.
> In my login page's submit button I just say if the "password is correct"
> then...
> session("IsAdmin") =3D True
> In my admin only pages I check if session("IsAdmin") =3D True
> If it's NOT then I redirect them to the login.aspx page.
> Is this solution pretty solid, or is it easy to hack? =A0I keep the passwo=[/color
]
rd
> in the web.config appsettings section so it's easy to change.
> I know I could use Membership stuff, but I'm just doing a simple, quick
> website.
> Your thoughts are appreciated!
I'd look at Jesse's recommendation about using the built-in membership
system in ASP.Net 2.0 if you really want to have some flexibility. You can
then use Roles to manage your users. For administrators, you can create an
Admin role and assign the users to that role. Then all you have to do is
test if the user is in that role. Actually, better yet, you can set the
authorization section of the web.config file so that only certain users or
roles have access to particular files or folders. This let's you tweak
security in a config file without worrying about coding it in every single
page.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression
"Bobby Edward" <test@.test.com> wrote in message
news:%23dULGfvfIHA.1188@.TK2MSFTNGP04.phx.gbl...
>I am creating a simple website with a login page and some "admin only"
>pages.
> In my login page's submit button I just say if the "password is correct"
> then...
> session("IsAdmin") = True
> In my admin only pages I check if session("IsAdmin") = True
> If it's NOT then I redirect them to the login.aspx page.
> Is this solution pretty solid, or is it easy to hack? I keep the password
> in the web.config appsettings section so it's easy to change.
> I know I could use Membership stuff, but I'm just doing a simple, quick
> website.
> Your thoughts are appreciated!
>

Thread accessing session variables?

I need to spin of a thread that periodically checks the Application
state. How can a thread access Application or Session states? Send it
the httpContext?

Thanks for your help.The httpcontext is owned by the main thread so you will need to send in a
reference to the object to the thread. Here is an example:
function(System.Web.HttpContext Stream)

{
Stream.Response.Write("vlah");
}
call it like so
function(HttpContext.Current);

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Bruce W.1" <no@.direct.email> wrote in message
news:401B0E42.3A4D549E@.direct.email...
> I need to spin of a thread that periodically checks the Application
> state. How can a thread access Application or Session states? Send it
> the httpContext?
> Thanks for your help.
I don't think this will work. If the thread is running separately from the
main Page execution thread, the Page may have already been processed, in
which case the Response and Request would not be available.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:#0T6qXB6DHA.1632@.TK2MSFTNGP12.phx.gbl...
> The httpcontext is owned by the main thread so you will need to send in a
> reference to the object to the thread. Here is an example:
> function(System.Web.HttpContext Stream)
> {
> Stream.Response.Write("vlah");
> }
> call it like so
> function(HttpContext.Current);
> --
> Regards,
> Alvin Bruney [ASP.NET MVP]
> Got tidbits? Get it here...
> http://tinyurl.com/3he3b
> "Bruce W.1" <no@.direct.email> wrote in message
> news:401B0E42.3A4D549E@.direct.email...
> > I need to spin of a thread that periodically checks the Application
> > state. How can a thread access Application or Session states? Send it
> > the httpContext?
> > Thanks for your help.
Right. I didn't consider that context. In that case the main thread would
need to wait on the worker thread to be finished.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Kevin Spencer" <kevin@.takempis.com> wrote in message
news:OznQqhB6DHA.3308@.TK2MSFTNGP11.phx.gbl...
> I don't think this will work. If the thread is running separately from the
> main Page execution thread, the Page may have already been processed, in
> which case the Response and Request would not be available.
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
> "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
> news:#0T6qXB6DHA.1632@.TK2MSFTNGP12.phx.gbl...
> > The httpcontext is owned by the main thread so you will need to send in
a
> > reference to the object to the thread. Here is an example:
> > function(System.Web.HttpContext Stream)
> > {
> > Stream.Response.Write("vlah");
> > }
> > call it like so
> > function(HttpContext.Current);
> > --
> > Regards,
> > Alvin Bruney [ASP.NET MVP]
> > Got tidbits? Get it here...
> > http://tinyurl.com/3he3b
> > "Bruce W.1" <no@.direct.email> wrote in message
> > news:401B0E42.3A4D549E@.direct.email...
> > > I need to spin of a thread that periodically checks the Application
> > > state. How can a thread access Application or Session states? Send
it
> > > the httpContext?
> > > > Thanks for your help.
> Right. I didn't consider that context. In that case the main thread would
> need to wait on the worker thread to be finished.

That would do it. However, it would most probably also eliminate the benefit
that the poster was trying to obtain by using a separate thread. Possibly
not.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:O4UfnND6DHA.2656@.TK2MSFTNGP11.phx.gbl...
> Right. I didn't consider that context. In that case the main thread would
> need to wait on the worker thread to be finished.
> --
> Regards,
> Alvin Bruney [ASP.NET MVP]
> Got tidbits? Get it here...
> http://tinyurl.com/3he3b
> "Kevin Spencer" <kevin@.takempis.com> wrote in message
> news:OznQqhB6DHA.3308@.TK2MSFTNGP11.phx.gbl...
> > I don't think this will work. If the thread is running separately from
the
> > main Page execution thread, the Page may have already been processed, in
> > which case the Response and Request would not be available.
> > --
> > HTH,
> > Kevin Spencer
> > .Net Developer
> > Microsoft MVP
> > Big things are made up
> > of lots of little things.
> > "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
> > news:#0T6qXB6DHA.1632@.TK2MSFTNGP12.phx.gbl...
> > > The httpcontext is owned by the main thread so you will need to send
in
> a
> > > reference to the object to the thread. Here is an example:
> > > function(System.Web.HttpContext Stream)
> > > > {
> > > Stream.Response.Write("vlah");
> > > }
> > > call it like so
> > > function(HttpContext.Current);
> > > > --
> > > Regards,
> > > Alvin Bruney [ASP.NET MVP]
> > > Got tidbits? Get it here...
> > > http://tinyurl.com/3he3b
> > > "Bruce W.1" <no@.direct.email> wrote in message
> > > news:401B0E42.3A4D549E@.direct.email...
> > > > I need to spin of a thread that periodically checks the Application
> > > > state. How can a thread access Application or Session states? Send
> it
> > > > the httpContext?
> > > > > > Thanks for your help.
> >