473,385 Members | 1,712 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,385 software developers and data experts.

Managed wrappers in ASP.NET Session

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
8 1368
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Marek Malowidzki | last post by:
Hi all, I am writing a component that exposes a C++ library as a .NET component. The approach is somewhat automatic: every library C++ class has its managed C++ counterpart that keeps a pointer...
3
by: Francis Urquhart | last post by:
I am trying to find the simplest possible way of writing a GUI to run on top of a standard C++ library written in VC++. I would like to avoid MFCs, COM, and if possible .Net wrappers. The goal...
3
by: mirek | last post by:
Hi, I've got problem building managed class library to wrap unmanaged code. I created managed class library using standard patten: #include "../Unmanaged/Class1.h" //Class1 unmanaged ...
4
by: Tim Menninger | last post by:
Just started working on this and have not found any real good resources out there. We have a lot of native C++ Dll code that we use for our app. We want to share the code so that C# ASP.net code...
7
by: Salvador | last post by:
Hi, I am using WMI to gather information about different computers (using win2K and win 2K3), checking common classes and also WMI load balance. My application runs every 1 minute and reports...
1
by: TC | last post by:
Every time I open my project, I get a warning which says "There are updated custom wrappers available for the following referenced components: Office." When I double-click on the warning, I get...
6
by: Vijay | last post by:
Hi, I am faced with the following common managed/unmanaged C++ interop problem: - I have a .NET form that acts as a front end GUI to a processing engine in the background. The processing...
1
by: stillh2os | last post by:
Hello. I'm new to .NET, and I'm trying to implement a callback function. I want my managed C++ code to call an unmanaged function, passing in a callback function that the unmanaged C/C++ code...
5
by: Maxim | last post by:
Hi all, I'm calling a COM Interface method that returnes SafeArray wrapped into variant. Is it possible to convert it to managed array? Because working with SAFEARRAY directly is a bit...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.