By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,146 Members | 1,614 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,146 IT Pros & Developers. It's quick & easy.

Managed wrappers in ASP.NET Session

P: n/a
Hi,
Is it safe to put my objects that are managed c++ wrappers to the
session? I want to pass them from one page to the other in the session
object but I noticed strange (maybe it is ok) behaviour: sometimes
destructors from unmanaged classes (that are being wrapped by my
wrappers) are called when it's not needed.
Thanks in advance for any suggestions.

Regards,
mirek

Nov 17 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Hi,

Basically yes, but make sure that the unmanaged code isn't STA (probably
not if you wrote it in C++).

Personally I donít like to use the session and in particular not to
store objects in the session. Can you share with us why you need to do
it ?
if you just need to pass them between pages that use transfer to
navigate between them you can use Context instead of session.

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #2

P: n/a
Hi,
Thanks for your reply.

Natty Gur wrote:
Personally I donít like to use the session and in particular not to
store objects in the session. Can you share with us why you need to do
it ? We've developed desktop appliaction in C++ (MFC) and fortunatelly we
separated code to have "business objects" classes in C++. Now we are
trying to implement web interface using ASP.NET and wrapping our
business classes to Managed C+ to be used on ASP.NET pages.

The first need was to store our user object (from business layer) in the
user's session so we could get user details, specific permission and
many other user's data on every page. Finally as there were problems I
was talking previuosly I've implemented global map where are put these
user objects (the session id is the key of this map) and it seems to
behave correct. (Also one advantage of this is that I am able to list
logged users or restrict that one user can only have one session.)

Another use of object in session is when I have multi page editing
(something like a wizard). On the first page I create my business
object, on submit I fill it with field values and pass it in the session
to the next page.
if you just need to pass them between pages that use transfer to
navigate between them you can use Context instead of session.

You mean Server.Transfer? It would be ok but I don't like that the url
isn't updated in the user's browser. It could be quite confusing for him
and refreshing a page isn't possible.
Reagrds,
mirek

Nov 17 '05 #3

P: n/a
Hi,

I think that if you will break your program into 3 layer (Visualization,
Business logic, Data) you can prevent from saving object in the session.
in such application you will need just to save data of your users in the
session / application and you can use BL objects just to Process and
handle the data. You actually done it by using global map but you save
the data with the logic and I would recommend separating them. Behind
software design perspective of separating data from logic you can see
advantage of that approach in busy web application where thousands of
users hit the server. In that case there will be hundreds of Objects in
the map that increase the server memory usage. But if you will store
just the data in the session and separate object will be use to enforce
logic rules on that data you will end up with less objects and memory
usage.

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #4

P: n/a
Hi,

I think that if you will break your program into 3 layer (Visualization,
Business logic, Data) you can prevent from saving object in the session.
in such application you will need just to save data of your users in the
session / application and you can use BL objects just to Process and
handle the data. You actually done it by using global map but you save
the data with the logic and I would recommend separating them. Behind
software design perspective of separating data from logic you can see
advantage of that approach in busy web application where thousands of
users hit the server. In that case there will be hundreds of Objects in
the map that increase the server memory usage. But if you will store
just the data in the session and separate object will be use to enforce
logic rules on that data you will end up with less objects and memory
usage.

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #5

P: n/a
Natty Gur wrote:
I think that if you will break your program into 3 layer (Visualization,
Business logic, Data) you can prevent from saving object in the session.
in such application you will need just to save data of your users in the
session / application and you can use BL objects just to Process and
handle the data. You actually done it by using global map but you save
the data with the logic and I would recommend separating them. Behind
software design perspective of separating data from logic you can see
advantage of that approach in busy web application where thousands of
users hit the server. In that case there will be hundreds of Objects in
the map that increase the server memory usage. But if you will store
just the data in the session and separate object will be use to enforce
logic rules on that data you will end up with less objects and memory
usage.

Yes, I know that the best would be make the layers you mentioned or
implement from scratch but unfortunatelly I haven't got enough time (who
has it? :)).
You said that you would store _data_ instead of objects in the session.
Could you explain it more or maybe small example. If I want to store
user data to the session so it would be accesible from every page, I'd
have to store in session following example values: permission="qwerty",
contacts=[ArrayList of contacts], last_login_date="28/01/2003", etc? I'd
say it's quite messy. The best would be "User" data object with
properties stored in the session on login, and then retrieved on every
page. Is my thinking OK? :)

Regards,
mirek

Nov 17 '05 #6

P: n/a
Natty Gur wrote:
I think that if you will break your program into 3 layer (Visualization,
Business logic, Data) you can prevent from saving object in the session.
in such application you will need just to save data of your users in the
session / application and you can use BL objects just to Process and
handle the data. You actually done it by using global map but you save
the data with the logic and I would recommend separating them. Behind
software design perspective of separating data from logic you can see
advantage of that approach in busy web application where thousands of
users hit the server. In that case there will be hundreds of Objects in
the map that increase the server memory usage. But if you will store
just the data in the session and separate object will be use to enforce
logic rules on that data you will end up with less objects and memory
usage.

Yes, I know that the best would be make the layers you mentioned or
implement from scratch but unfortunatelly I haven't got enough time (who
has it? :)).
You said that you would store _data_ instead of objects in the session.
Could you explain it more or maybe small example. If I want to store
user data to the session so it would be accesible from every page, I'd
have to store in session following example values: permission="qwerty",
contacts=[ArrayList of contacts], last_login_date="28/01/2003", etc? I'd
say it's quite messy. The best would be "User" data object with
properties stored in the session on login, and then retrieved on every
page. Is my thinking OK? :)

Regards,
mirek

Nov 17 '05 #7

P: n/a
Hi,

User data object is just fine :-) (You can use DataTable) as long as you
take in account the memory consequences of storing object that consume X
bytes * Y users.

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #8

P: n/a
Hi,

User data object is just fine :-) (You can use DataTable) as long as you
take in account the memory consequences of storing object that consume X
bytes * Y users.

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.