Showing posts with label session. Show all posts
Showing posts with label session. Show all posts

Wednesday, March 28, 2012

Third party cookies and P3P

Does anyone have any documentation on compact privacy policy
and asp.net session or http session cookies.

I have a third party app that relies on a session cookie to maintain
the state of my app in a users site.

Currently my P3P policy is causing IE6 to reject my third party session
cookie.

I have my P3P working and do not collect personal info, add headers
including my
P3P info as the per documentation I have found so far.

Is there anything else I can do from asp.net to get my third party session
accepted
in IE6 ?

Chris LangI am having the same problem. The default configuration of Internet
Explorer seems to block all third party cookies, even if they are just
for state information. I can't figure out what I can do with my p3p
policy settings to get around this. Does anyone know how?

I'm trying to make it so that my site can be embedded inside other sites
using frames. When a code is attached to the url to my site, then my
own header and footer banners get turned off. I use a cookie so track
that the site is embedded, that way I don't have to update all the
hyperlinks on the entire site dynamically to maintain state information.

Thanks anyone for help.

Meet people for friendship, contacts,
or romance using free instant messaging software! See a picture you
like? Click once for a private conversation with that person!

www.SEN.us

*** Sent via Developersdex http://www.developersdex.com ***

Monday, March 26, 2012

This drives me crazy

Hello,
I have this:
Select Case Session("culture4web")
Case "pt-PT"
Dim topMenuItems() As String = {"Home", "Conteúdos", "Xtras", " ", "Web", "Company"}
Case "en-GB"
Dim topMenuItems() As String = {"Home", "Conteúdos", "Xtras", " ", "Web", "Company"}
End Select
Call_Function (topMenuItems)
I am having problems because the variable disapears outside of Case Statement.
How can I solve this?
Thanks,
Miguel

Always try and define your variables outside conditional statements...
Dim topMenuItems() As String
Select Case Session("culture4web")
Case "pt-PT"
topMenuItems()= {"Home", "Conteúdos", "Xtras", " ", "Web", "Company"}
Case "en-GB"
topMenuItems() = {"Home", "Conteúdos", "Xtras", " ", "Web", "Company"}
End Select

.NET introduced an extended scoping model, block-level variables are now block-local.
Declare your dependant variables outside theSelect...End Select block:
Dim topMenuItem() As String
Select Case Session("culture4web")
Case "pt-PT"
topMenuItems = {"Home", "Conteúdos", "Xtras", " ", "Web", "Company"}
End Select
Call_Function(topMenuItems)

this keyword

Is there any difference between using

this.session["Some_Value"] and session["Some_Value"]

No

"this" in C# points to the current object where the code is located.


No there aint any difference. Session is for the entire user session.

Thanks


Will there be any performace difference
No, I prefer to use this when I call methods and want to access private fields etc..
cant we acess private variable directly?Tongue Tied

private variable isnotaccessible outside the class, butaccessible inside the class.

public varialbe is bothaccessible outside and inside the class.

hope it helps


I am not trying to acess the private variable outside the class nor even my doubt is about that.

I would like to know the purpose ofthis keyword while accesible private variables either likethis.PrivateVariableNameor bythis.PublicPropertyName[which gets the private variable]


Check this:

// keywords_this.cs// this exampleusing System;class Employee{ private string name; private stringalias; private decimal salary = 3000.00m; // Constructor: public Employee(stringname, stringalias) { // Use this to qualify the fields, name and alias:this.name =name;this.alias =alias; } // Printing method: public void printEmployee() { Console.WriteLine("Name: {0}\nAlias: {1}", name, alias); // Passing the object to the CalcTax method by using this: Console.WriteLine("Taxes: {0:C}", Tax.CalcTax(this)); } public decimal Salary { get { return salary; } }}class Tax{ public static decimal CalcTax(Employee E) { return 0.08m * E.Salary; }}class MainClass{ static void Main() { // Create objects: Employee E1 = new Employee("John M. Trainer", "jtrainer"); // Display results: E1.printEmployee(); }}

Saturday, March 24, 2012

this.Connection.Close(); does not close the Oracle session! Pleasehelp!

Hi all!

I'm writing an ASP.NET web application that uses an Oracle database.

I OPEN the Oracle connection by using the following code:

if (this.ConnectionString != "")
{
this.Connection = new OracleConnection(this.ConnectionString);
this.Connection.Open();
return;
}

I then create the command object by using the following:

OracleCommand DBCmd = new
OracleCommand("PRL_STORE_PAYMENT_REQ_PKG.GET_PAYMENT_REQ_LOOKUP",
objConnect.Connection);
DBCmd.CommandType = System.Data.CommandType.StoredProcedure;

I then I run the OracleCommand.ExecuteReader method to execute the
stored procedure.

I then CLOSE the connection by using the
this.Connection.Close(); command.

However, the sessions stay active!!!
I have a very angry DBA on my tail about this one!
Please help!

Thanks
SteveI'm pretty sure "OracleConnection" is not a standard Framework class. You'll
probably have better luck asking the component vendor (or in their forums).
My guess is that it has to do with connection pooling. Do the number of
connections grow endlessly, or are they reused over and over? If it's the
later, then you should actually have a very happy DBA.

Scott

"S_K" <steve_kershaw@.yahoo.comwrote in message
news:3619d1f2-ef79-41cb-a0af-5df58dd223a0@.e10g2000prf.googlegroups.com...

Quote:

Originally Posted by

Hi all!
>
I'm writing an ASP.NET web application that uses an Oracle database.
>
I OPEN the Oracle connection by using the following code:
>
if (this.ConnectionString != "")
{
this.Connection = new OracleConnection(this.ConnectionString);
this.Connection.Open();
return;
}
>
I then create the command object by using the following:
>
OracleCommand DBCmd = new
OracleCommand("PRL_STORE_PAYMENT_REQ_PKG.GET_PAYMENT_REQ_LOOKUP",
objConnect.Connection);
DBCmd.CommandType = System.Data.CommandType.StoredProcedure;
>
I then I run the OracleCommand.ExecuteReader method to execute the
stored procedure.
>
I then CLOSE the connection by using the
this.Connection.Close(); command.
>
However, the sessions stay active!!!
I have a very angry DBA on my tail about this one!
Please help!
>
Thanks
Steve


Did you close the reader?

if(null!=reader)
{
reader.Close();
}

?

A reader is a live firehouse...thus you use it, then you tidy up.
You can't get reader, close the connection , then use the reader. That
doesn't make sense.

Use the reader as quickly as possible, then close it.

"S_K" <steve_kershaw@.yahoo.comwrote in message
news:3619d1f2-ef79-41cb-a0af-5df58dd223a0@.e10g2000prf.googlegroups.com...

Quote:

Originally Posted by

Hi all!
>
I'm writing an ASP.NET web application that uses an Oracle database.
>
I OPEN the Oracle connection by using the following code:
>
if (this.ConnectionString != "")
{
this.Connection = new OracleConnection(this.ConnectionString);
this.Connection.Open();
return;
}
>
I then create the command object by using the following:
>
OracleCommand DBCmd = new
OracleCommand("PRL_STORE_PAYMENT_REQ_PKG.GET_PAYMENT_REQ_LOOKUP",
objConnect.Connection);
DBCmd.CommandType = System.Data.CommandType.StoredProcedure;
>
I then I run the OracleCommand.ExecuteReader method to execute the
stored procedure.
>
I then CLOSE the connection by using the
this.Connection.Close(); command.
>
However, the sessions stay active!!!
I have a very angry DBA on my tail about this one!
Please help!
>
Thanks
Steve


you will need to turn connection pooling off (see your connect string
properties). with pooling on, connection.close only returns the connection to
the pool, it does not close it. you may make your dba happy by lowing the
pool timeout.

-- bruce (sqlwork.com)

"S_K" wrote:

Quote:

Originally Posted by

Hi all!
>
I'm writing an ASP.NET web application that uses an Oracle database.
>
I OPEN the Oracle connection by using the following code:
>
if (this.ConnectionString != "")
{
this.Connection = new OracleConnection(this.ConnectionString);
this.Connection.Open();
return;
}
>
I then create the command object by using the following:
>
OracleCommand DBCmd = new
OracleCommand("PRL_STORE_PAYMENT_REQ_PKG.GET_PAYMENT_REQ_LOOKUP",
objConnect.Connection);
DBCmd.CommandType = System.Data.CommandType.StoredProcedure;
>
I then I run the OracleCommand.ExecuteReader method to execute the
stored procedure.
>
I then CLOSE the connection by using the
this.Connection.Close(); command.
>
However, the sessions stay active!!!
I have a very angry DBA on my tail about this one!
Please help!
>
Thanks
Steve
>


On Dec 6, 3:13 pm, bruce barker
<brucebar...@.discussions.microsoft.comwrote:

Quote:

Originally Posted by

you will need to turn connection pooling off (see your connect string
properties). with pooling on, connection.close only returns the connection to
the pool, it does not close it. you may make your dba happy by lowing the
pool timeout.
>
-- bruce (sqlwork.com)
>
>
>
"S_K" wrote:

Quote:

Originally Posted by

Hi all!


>

Quote:

Originally Posted by

I'm writing an ASP.NET web application that uses an Oracle database.


>

Quote:

Originally Posted by

I OPEN the Oracle connection by using the following code:


>

Quote:

Originally Posted by

if (this.ConnectionString != "")
{
this.Connection = new OracleConnection(this.ConnectionString);
this.Connection.Open();
return;
}


>

Quote:

Originally Posted by

I then create the command object by using the following:


>

Quote:

Originally Posted by

OracleCommand DBCmd = new
OracleCommand("PRL_STORE_PAYMENT_REQ_PKG.GET_PAYMENT_REQ_LOOKUP",
objConnect.Connection);
DBCmd.CommandType = System.Data.CommandType.StoredProcedure;


>

Quote:

Originally Posted by

I then I run the OracleCommand.ExecuteReader method to execute the
stored procedure.


>

Quote:

Originally Posted by

I then CLOSE the connection by using the
this.Connection.Close(); command.


>

Quote:

Originally Posted by

However, the sessions stay active!!!
I have a very angry DBA on my tail about this one!
Please help!


>

Quote:

Originally Posted by

Thanks
Steve- Hide quoted text -


>
- Show quoted text -


I don't actually CLOSE the reader but I DO Dispose the reader:
reader.Dispose();

Doesn't that close the reader as well?

Also, how do you turn off the connection pooling in the connection
string? All I have is the basic connection string.

Thanks for your quick replies.

Steve
no, dispose will return it to the pool if pooling is enabled (all dispose
does is call close if needed).

you will need the connection string settings docs for the driver you are
using..

-- bruce (sqlwork.com)

"S_K" wrote:

Quote:

Originally Posted by

On Dec 6, 3:13 pm, bruce barker
<brucebar...@.discussions.microsoft.comwrote:

Quote:

Originally Posted by

you will need to turn connection pooling off (see your connect string
properties). with pooling on, connection.close only returns the connection to
the pool, it does not close it. you may make your dba happy by lowing the
pool timeout.

-- bruce (sqlwork.com)

"S_K" wrote:

Quote:

Originally Posted by

Hi all!


Quote:

Originally Posted by

I'm writing an ASP.NET web application that uses an Oracle database.


Quote:

Originally Posted by

I OPEN the Oracle connection by using the following code:


Quote:

Originally Posted by

if (this.ConnectionString != "")
{
this.Connection = new OracleConnection(this.ConnectionString);
this.Connection.Open();
return;
}


Quote:

Originally Posted by

I then create the command object by using the following:


Quote:

Originally Posted by

OracleCommand DBCmd = new
OracleCommand("PRL_STORE_PAYMENT_REQ_PKG.GET_PAYMENT_REQ_LOOKUP",
objConnect.Connection);
DBCmd.CommandType = System.Data.CommandType.StoredProcedure;


Quote:

Originally Posted by

I then I run the OracleCommand.ExecuteReader method to execute the
stored procedure.


Quote:

Originally Posted by

I then CLOSE the connection by using the
this.Connection.Close(); command.


Quote:

Originally Posted by

However, the sessions stay active!!!
I have a very angry DBA on my tail about this one!
Please help!


Quote:

Originally Posted by

Thanks
Steve- Hide quoted text -


- Show quoted text -


>
I don't actually CLOSE the reader but I DO Dispose the reader:
reader.Dispose();
>
Doesn't that close the reader as well?
>
Also, how do you turn off the connection pooling in the connection
string? All I have is the basic connection string.
>
Thanks for your quick replies.
>
Steve
>


OracleConnection is in the System.Data.OracleClient namespace.

Although Oracle also provides such a class, in their
Oracle.DataAccess.Client namespace.

If the connection pool advice doesn't work out, try also calling
Dispose on the connection. Unless the issue has been resolved in a
recent version, there's a flaw in the Framework class that
necessitates this. And it can't hurt in any event.

On Dec 6, 4:52 pm, "Scott Roberts" <srobe...@.no.spam.here-webworks-
software.comwrote:

Quote:

Originally Posted by

I'm pretty sure "OracleConnection" is not a standard Framework class. You'll
probably have better luck asking the component vendor (or in their forums).
My guess is that it has to do with connection pooling. Do the number of
connections grow endlessly, or are they reused over and over? If it's the
later, then you should actually have a very happy DBA.
>
Scott
>
"S_K" <steve_kers...@.yahoo.comwrote in message
>
news:3619d1f2-ef79-41cb-a0af-5df58dd223a0@.e10g2000prf.googlegroups.com...
>
>
>

Quote:

Originally Posted by

Hi all!


>

Quote:

Originally Posted by

I'm writing an ASP.NET web application that uses an Oracle database.


>

Quote:

Originally Posted by

I OPEN the Oracle connection by using the following code:


>

Quote:

Originally Posted by

if (this.ConnectionString != "")
{
this.Connection = new OracleConnection(this.ConnectionString);
this.Connection.Open();
return;
}


>

Quote:

Originally Posted by

I then create the command object by using the following:


>

Quote:

Originally Posted by

OracleCommand DBCmd = new
OracleCommand("PRL_STORE_PAYMENT_REQ_PKG.GET_PAYMENT_REQ_LOOKUP",
objConnect.Connection);
DBCmd.CommandType = System.Data.CommandType.StoredProcedure;


>

Quote:

Originally Posted by

I then I run the OracleCommand.ExecuteReader method to execute the
stored procedure.


>

Quote:

Originally Posted by

I then CLOSE the connection by using the
this.Connection.Close(); command.


>

Quote:

Originally Posted by

However, the sessions stay active!!!
I have a very angry DBA on my tail about this one!
Please help!


>

Quote:

Originally Posted by

Thanks
Steve- Hide quoted text -


>
- Show quoted text -

this.Connection.Close(); does not close the Oracle session! Please

Hi all!
I'm writing an ASP.NET web application that uses an Oracle database.
I OPEN the Oracle connection by using the following code:
if (this.ConnectionString != "")
{
this.Connection = new OracleConnection(this.ConnectionString);
this.Connection.Open();
return;
}
I then create the command object by using the following:
OracleCommand DBCmd = new
OracleCommand("PRL_STORE_PAYMENT_REQ_PKG.GET_PAYMENT_REQ_LOOKUP",
objConnect.Connection);
DBCmd.CommandType = System.Data.CommandType.StoredProcedure;
I then I run the OracleCommand.ExecuteReader method to execute the
stored procedure.
I then CLOSE the connection by using the
this.Connection.Close(); command.
However, the sessions stay active!!!
I have a very DBA on my tail about this one!
Please help!
Thanks
Steveyou will need to turn connection pooling off (see your connect string
properties). with pooling on, connection.close only returns the connection t
o
the pool, it does not close it. you may make your dba happy by lowing the
pool timeout.
-- bruce (sqlwork.com)
"S_K" wrote:

> Hi all!
> I'm writing an ASP.NET web application that uses an Oracle database.
> I OPEN the Oracle connection by using the following code:
> if (this.ConnectionString != "")
> {
> this.Connection = new OracleConnection(this.ConnectionString);
> this.Connection.Open();
> return;
> }
> I then create the command object by using the following:
> OracleCommand DBCmd = new
> OracleCommand("PRL_STORE_PAYMENT_REQ_PKG.GET_PAYMENT_REQ_LOOKUP",
> objConnect.Connection);
> DBCmd.CommandType = System.Data.CommandType.StoredProcedure;
> I then I run the OracleCommand.ExecuteReader method to execute the
> stored procedure.
> I then CLOSE the connection by using the
> this.Connection.Close(); command.
> However, the sessions stay active!!!
> I have a very DBA on my tail about this one!
> Please help!
> Thanks
> Steve
>

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.
> >

Thread class and Session variable

Hi All,

I am trying to perform a non-CPU bound operation in an asynchronous fashion
using 'Thread' and a delegate. Basically, I am spawning a thread using
ThreadStart and Thread.

My non-CPU bound operation needs to have access to Session variables; Even
though I embedded the state information (which also includes the context
object) in an object and passed the object to the Thread , I am unable to
access the Session variables. The system throws a Null Object Reference error.

Since the thread that I am spawning is not from the CLR thread pool, it is
not able to access the Session variable. Am I right? How can a system thread
get access to the Session variables of the current HTTPRequest?

I hope I articulated my problem. If not, please let me know.

Any pointers will be appreciated!This example ( albiet in Visual Basic.NET ) seems to work ok. Im not sure
what you are doing differently , or if I have misunderstood you ?

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim myThread As New Threading.Thread(AddressOf mySpawned)

Session("TestMe") = "Hello World"

myThread.Start()

End Sub

Private Sub mySpawned()

Dim s As String = Session("TestMe")

End Sub

"Diffident" <Diffident@.discussions.microsoft.comwrote in message
news:32A19AC0-DB0F-4120-8BF6-4E1539BEB0B7@.microsoft.com...

Quote:

Originally Posted by

Hi All,
>
I am trying to perform a non-CPU bound operation in an asynchronous
fashion
using 'Thread' and a delegate. Basically, I am spawning a thread using
ThreadStart and Thread.
>
My non-CPU bound operation needs to have access to Session variables; Even
though I embedded the state information (which also includes the context
object) in an object and passed the object to the Thread , I am unable to
access the Session variables. The system throws a Null Object Reference
error.
>
Since the thread that I am spawning is not from the CLR thread pool, it is
not able to access the Session variable. Am I right? How can a system
thread
get access to the Session variables of the current HTTPRequest?
>
I hope I articulated my problem. If not, please let me know.
>
Any pointers will be appreciated!
>
>


Hi OHM,

Thanks for your response.

Here is what I am trying to do (in C#):

=====

ThreadStart t = new ThreadStart(LongDBProcess)
// LongDBProcess is a time-consuming process
Thread ts = new Thread(t);
t.start(); //At this point, system thread will be created and not
the CLR thread

====

I need to have access to Session variables inside my LongDBProcess...

private void LongDBProcess()
{
Session["IDCounter"] = i+1; //At this point, I am getting null
reference
}

If I am correct, the thread is not able to access the session. Probably this
thread's scope is outside the Application Domain whereas the session data
will be inside the Application Domain...am I correct?

Thanks for your pointers.

"OHM" wrote:

Quote:

Originally Posted by

This example ( albiet in Visual Basic.NET ) seems to work ok. Im not sure
what you are doing differently , or if I have misunderstood you ?
>
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
>
Dim myThread As New Threading.Thread(AddressOf mySpawned)
>
Session("TestMe") = "Hello World"
>
myThread.Start()
>
End Sub
>
>
Private Sub mySpawned()
>
Dim s As String = Session("TestMe")
>
End Sub
>
>
>
>
>
"Diffident" <Diffident@.discussions.microsoft.comwrote in message
news:32A19AC0-DB0F-4120-8BF6-4E1539BEB0B7@.microsoft.com...

Quote:

Originally Posted by

Hi All,

I am trying to perform a non-CPU bound operation in an asynchronous
fashion
using 'Thread' and a delegate. Basically, I am spawning a thread using
ThreadStart and Thread.

My non-CPU bound operation needs to have access to Session variables; Even
though I embedded the state information (which also includes the context
object) in an object and passed the object to the Thread , I am unable to
access the Session variables. The system throws a Null Object Reference
error.

Since the thread that I am spawning is not from the CLR thread pool, it is
not able to access the Session variable. Am I right? How can a system
thread
get access to the Session variables of the current HTTPRequest?

I hope I articulated my problem. If not, please let me know.

Any pointers will be appreciated!


>
>
>


Hmm, not sure on this one. If you can do it with vb.net you should be able
to do it somehow with C#, but I cant get it to work either. The delegate is
obviously working ok, but it seems to have lost its connection to the
context.

I think its probably the way the thread has been started, but I dont
normally do that much with threading It's not something which rattles off
the tip of my head.

My suggestion is to repost this question on the C# newsgroup, someone there
is bound to have an answer pretty quick.

"Diffident" <Diffident@.discussions.microsoft.comwrote in message
news:92659A98-C334-4834-B95B-E74F14878594@.microsoft.com...

Quote:

Originally Posted by

Hi OHM,
>
Thanks for your response.
>
Here is what I am trying to do (in C#):
>
=====
>
ThreadStart t = new ThreadStart(LongDBProcess)
// LongDBProcess is a time-consuming process
Thread ts = new Thread(t);
t.start(); //At this point, system thread will be created and not
the CLR thread
>
====
>
I need to have access to Session variables inside my LongDBProcess...
>
private void LongDBProcess()
{
Session["IDCounter"] = i+1; //At this point, I am getting
null
reference
}
>
If I am correct, the thread is not able to access the session. Probably
this
thread's scope is outside the Application Domain whereas the session data
will be inside the Application Domain...am I correct?
>
Thanks for your pointers.
>
"OHM" wrote:
>

Quote:

Originally Posted by

>This example ( albiet in Visual Basic.NET ) seems to work ok. Im not sure
>what you are doing differently , or if I have misunderstood you ?
>>
>Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>System.EventArgs) Handles MyBase.Load
>>
> Dim myThread As New Threading.Thread(AddressOf mySpawned)
>>
> Session("TestMe") = "Hello World"
>>
> myThread.Start()
>>
> End Sub
>>
>>
> Private Sub mySpawned()
>>
> Dim s As String = Session("TestMe")
>>
> End Sub
>>
>>
>>
>>
>>
>"Diffident" <Diffident@.discussions.microsoft.comwrote in message
>news:32A19AC0-DB0F-4120-8BF6-4E1539BEB0B7@.microsoft.com...

Quote:

Originally Posted by

Hi All,
>
I am trying to perform a non-CPU bound operation in an asynchronous
fashion
using 'Thread' and a delegate. Basically, I am spawning a thread using
ThreadStart and Thread.
>
My non-CPU bound operation needs to have access to Session variables;
Even
though I embedded the state information (which also includes the
context
object) in an object and passed the object to the Thread , I am unable
to
access the Session variables. The system throws a Null Object Reference
error.
>
Since the thread that I am spawning is not from the CLR thread pool, it
is
not able to access the Session variable. Am I right? How can a system
thread
get access to the Session variables of the current HTTPRequest?
>
I hope I articulated my problem. If not, please let me know.
>
Any pointers will be appreciated!
>
>


>>
>>
>>


You want to use Asynchronous calls here, either with a Delegate, or using the
2.0 version, the Page class supports Asynchronous page methods and the
context can be passed.

Here is an example article that covers some of this:

http://www.eggheadcafe.com/articles/20060918.asp
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Diffident" wrote:

Quote:

Originally Posted by

Hi All,
>
I am trying to perform a non-CPU bound operation in an asynchronous fashion
using 'Thread' and a delegate. Basically, I am spawning a thread using
ThreadStart and Thread.
>
My non-CPU bound operation needs to have access to Session variables; Even
though I embedded the state information (which also includes the context
object) in an object and passed the object to the Thread , I am unable to
access the Session variables. The system throws a Null Object Reference error.
>
Since the thread that I am spawning is not from the CLR thread pool, it is
not able to access the Session variable. Am I right? How can a system thread
get access to the Session variables of the current HTTPRequest?
>
I hope I articulated my problem. If not, please let me know.
>
Any pointers will be appreciated!
>
>

Thread class and Session variable

Hi All,
I am trying to perform a non-CPU bound operation in an asynchronous fashion
using 'Thread' and a delegate. Basically, I am spawning a thread using
ThreadStart and Thread.
My non-CPU bound operation needs to have access to Session variables; Even
though I embedded the state information (which also includes the context
object) in an object and passed the object to the Thread , I am unable to
access the Session variables. The system throws a Null Object Reference erro
r.
Since the thread that I am spawning is not from the CLR thread pool, it is
not able to access the Session variable. Am I right? How can a system thread
get access to the Session variables of the current HTTPRequest?
I hope I articulated my problem. If not, please let me know.
Any pointers will be appreciated!This example ( albiet in Visual Basic.NET ) seems to work ok. Im not sure
what you are doing differently , or if I have misunderstood you ?
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim myThread As New Threading.Thread(AddressOf mySpawned)
Session("TestMe") = "Hello World"
myThread.Start()
End Sub
Private Sub mySpawned()
Dim s As String = Session("TestMe")
End Sub
"Diffident" <Diffident@.discussions.microsoft.com> wrote in message
news:32A19AC0-DB0F-4120-8BF6-4E1539BEB0B7@.microsoft.com...
> Hi All,
> I am trying to perform a non-CPU bound operation in an asynchronous
> fashion
> using 'Thread' and a delegate. Basically, I am spawning a thread using
> ThreadStart and Thread.
> My non-CPU bound operation needs to have access to Session variables; Even
> though I embedded the state information (which also includes the context
> object) in an object and passed the object to the Thread , I am unable to
> access the Session variables. The system throws a Null Object Reference
> error.
> Since the thread that I am spawning is not from the CLR thread pool, it is
> not able to access the Session variable. Am I right? How can a system
> thread
> get access to the Session variables of the current HTTPRequest?
> I hope I articulated my problem. If not, please let me know.
> Any pointers will be appreciated!
>
Hi OHM,
Thanks for your response.
Here is what I am trying to do (in C#):
=====
ThreadStart t = new ThreadStart(LongDBProcess)
// LongDBProcess is a time-consuming process
Thread ts = new Thread(t);
t.start(); //At this point, system thread will be created and not
the CLR thread
====
I need to have access to Session variables inside my LongDBProcess...
private void LongDBProcess()
{
Session["IDCounter"] = i+1; //At this point, I am getting null
reference
}
If I am correct, the thread is not able to access the session. Probably this
thread's scope is outside the Application Domain whereas the session data
will be inside the Application Domain...am I correct?
Thanks for your pointers.
"OHM" wrote:

> This example ( albiet in Visual Basic.NET ) seems to work ok. Im not sure
> what you are doing differently , or if I have misunderstood you ?
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Dim myThread As New Threading.Thread(AddressOf mySpawned)
> Session("TestMe") = "Hello World"
> myThread.Start()
> End Sub
>
> Private Sub mySpawned()
> Dim s As String = Session("TestMe")
> End Sub
>
>
> "Diffident" <Diffident@.discussions.microsoft.com> wrote in message
> news:32A19AC0-DB0F-4120-8BF6-4E1539BEB0B7@.microsoft.com...
>
>
Hmm, not sure on this one. If you can do it with vb.net you should be able
to do it somehow with C#, but I cant get it to work either. The delegate is
obviously working ok, but it seems to have lost its connection to the
context.
I think its probably the way the thread has been started, but I dont
normally do that much with threading It's not something which rattles off
the tip of my head.
My suggestion is to repost this question on the C# newsgroup, someone there
is bound to have an answer pretty quick.
"Diffident" <Diffident@.discussions.microsoft.com> wrote in message
news:92659A98-C334-4834-B95B-E74F14878594@.microsoft.com...
> Hi OHM,
> Thanks for your response.
> Here is what I am trying to do (in C#):
> =====
> ThreadStart t = new ThreadStart(LongDBProcess)
> // LongDBProcess is a time-consuming process
> Thread ts = new Thread(t);
> t.start(); //At this point, system thread will be created and not
> the CLR thread
> ====
> I need to have access to Session variables inside my LongDBProcess...
> private void LongDBProcess()
> {
> Session["IDCounter"] = i+1; //At this point, I am getting
> null
> reference
> }
> If I am correct, the thread is not able to access the session. Probably
> this
> thread's scope is outside the Application Domain whereas the session data
> will be inside the Application Domain...am I correct?
> Thanks for your pointers.
> "OHM" wrote:
>
You want to use Asynchronous calls here, either with a Delegate, or using th
e
2.0 version, the Page class supports Asynchronous page methods and the
context can be passed.
Here is an example article that covers some of this:
http://www.eggheadcafe.com/articles/20060918.asp
Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Diffident" wrote:

> Hi All,
> I am trying to perform a non-CPU bound operation in an asynchronous fashio
n
> using 'Thread' and a delegate. Basically, I am spawning a thread using
> ThreadStart and Thread.
> My non-CPU bound operation needs to have access to Session variables; Even
> though I embedded the state information (which also includes the context
> object) in an object and passed the object to the Thread , I am unable to
> access the Session variables. The system throws a Null Object Reference er
ror.
> Since the thread that I am spawning is not from the CLR thread pool, it is
> not able to access the Session variable. Am I right? How can a system thre
ad
> get access to the Session variables of the current HTTPRequest?
> I hope I articulated my problem. If not, please let me know.
> Any pointers will be appreciated!
>