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

how to transfer a class from 1 app to another

Perhaps an asp.net question but involves c# classes so I'd rather ask this
here. Here goes:

Lets say I have an asp.net app called Logon. When a user logs on in Logon,
a User class is populated with his / her name, department etc. After the
user has logged in I present him with a page that lets him go to other
websites -- app1 & app2.

The problem is when he is redirected over to app1 or app2, I want that User
class to come with him! Because the User class will tell me what kind of
user he is, permissions etc. I don't want to make him log on again. I want
to look at the User class that was populated in the previous application,
Logon. I just don't know the best way to transfer a class from 1 asp.net
application to another, or if there's a better architecture for this kind of
thing.
Basically if someone logs on thru our Logon app, every other app we redirect
him to should be able to interrogate the User class to find out what this
user can do in the application.

TY for any advice
Jason Shohet
Nov 15 '05 #1
8 1413
Jason,

First, you will need to have each app reference the same implementation
of the User class. This way, when you serialize it (whatever method you
use), you will have the same code running.

Once you do that, you can do a number of things. I think the easiest to
do would be to serialize the instance and then send that to the other app
somehow. You can post this information in a form, or you can store the
serialized content to a database, and then send a pointer to the other app
indicating where in the DB you can find it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

" Jason Shohet" <as****@hotmail.com> wrote in message
news:uH*************@TK2MSFTNGP10.phx.gbl...
Perhaps an asp.net question but involves c# classes so I'd rather ask this
here. Here goes:

Lets say I have an asp.net app called Logon. When a user logs on in Logon, a User class is populated with his / her name, department etc. After the
user has logged in I present him with a page that lets him go to other
websites -- app1 & app2.

The problem is when he is redirected over to app1 or app2, I want that User class to come with him! Because the User class will tell me what kind of
user he is, permissions etc. I don't want to make him log on again. I want to look at the User class that was populated in the previous application,
Logon. I just don't know the best way to transfer a class from 1 asp.net
application to another, or if there's a better architecture for this kind of thing.
Basically if someone logs on thru our Logon app, every other app we redirect him to should be able to interrogate the User class to find out what this
user can do in the application.

TY for any advice
Jason Shohet

Nov 15 '05 #2

" Jason Shohet" <as****@hotmail.com> wrote in message
news:uH*************@TK2MSFTNGP10.phx.gbl...
Perhaps an asp.net question but involves c# classes so I'd rather ask this
here. Here goes:

Lets say I have an asp.net app called Logon. When a user logs on in Logon, a User class is populated with his / her name, department etc. After the
user has logged in I present him with a page that lets him go to other
websites -- app1 & app2.

The problem is when he is redirected over to app1 or app2, I want that User class to come with him! Because the User class will tell me what kind of
user he is, permissions etc. I don't want to make him log on again. I want to look at the User class that was populated in the previous application,
Logon. I just don't know the best way to transfer a class from 1 asp.net
application to another, or if there's a better architecture for this kind of thing.
Basically if someone logs on thru our Logon app, every other app we redirect him to should be able to interrogate the User class to find out what this
user can do in the application.


Each asp.net app is in its own AppDomain, and so you will need to stick your
user object somewhere outside each AppDomain, and retrieve it from the other
AppDomain.

You could:
-Create a new asp.net app just for the User objects there and access them
through remoting or HTTP. EG: Server-side post to
http://localhost/LoginApp/GetUserInf...onID=123546789
-Store it in a database or a file
-Store it in a Memory Mapped file using the Caching Application Block for
..NET
http://msdn.microsoft.com/library/de...chingBlock.asp

David
Nov 15 '05 #3
Hi Jason,

Nicholas and David pretty much said how to do it, but as I was reading your
post I think that you are working on a intranet environment, if it's so try
to explore the possibility of using windows authentication, if you can use
it's better for you and for your users as they don't have to login and you
dont have to keep a reference to the logged user.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

" Jason Shohet" <as****@hotmail.com> wrote in message
news:uH*************@TK2MSFTNGP10.phx.gbl...
Perhaps an asp.net question but involves c# classes so I'd rather ask this
here. Here goes:

Lets say I have an asp.net app called Logon. When a user logs on in Logon, a User class is populated with his / her name, department etc. After the
user has logged in I present him with a page that lets him go to other
websites -- app1 & app2.

The problem is when he is redirected over to app1 or app2, I want that User class to come with him! Because the User class will tell me what kind of
user he is, permissions etc. I don't want to make him log on again. I want to look at the User class that was populated in the previous application,
Logon. I just don't know the best way to transfer a class from 1 asp.net
application to another, or if there's a better architecture for this kind of thing.
Basically if someone logs on thru our Logon app, every other app we redirect him to should be able to interrogate the User class to find out what this
user can do in the application.

TY for any advice
Jason Shohet

Nov 15 '05 #4
Thanks to you, Nicholas & David. I am OK with the first & 3rd suggestions,
and I'll try for the 3rd (windows auth.) first since its easier. But I have
never done what David suggested:

-Create a new asp.net app just for the User objects there and access them
through HTTP (or remoting, i suppose, in the c/s world). David gave the
example of a form (http) POST:
http://localhost/LoginApp/GetUserInf...onID=123546789

I am not sure how this works above. I am guessing that David is suggesting
that the user actually goes to the 2nd application first. There in
page_load it calls the LoginApp in an http request (above), but how? Can't
be a hyperlink :) although above it looks like one. And how do i get that
sessionID, and how does LoginApp return back the employee class object
(which I'll need in that 2nd application).

TY for all the help! -- Jason Shohet
Nov 15 '05 #5

" Jason Shohet" <as****@hotmail.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Thanks to you, Nicholas & David. I am OK with the first & 3rd suggestions, and I'll try for the 3rd (windows auth.) first since its easier. But I have never done what David suggested:

-Create a new asp.net app just for the User objects there and access them
through HTTP (or remoting, i suppose, in the c/s world). David gave the
example of a form (http) POST:
http://localhost/LoginApp/GetUserInf...onID=123546789

I am not sure how this works above. I am guessing that David is suggesting that the user actually goes to the 2nd application first. There in
page_load it calls the LoginApp in an http request (above), but how? Can't be a hyperlink :) although above it looks like one. And how do i get that sessionID, and how does LoginApp return back the employee class object
(which I'll need in that 2nd application).


It would work basically like this:

User starts at LoginApp/Login.aspx. This page validates the user's
credentials and creates a session for the user, and stores the user data in
a Application-scope hashtable keyed by a sessionID. Then the user clicks
over to another application. But LoginApp adds a session id to the url for
the other app. Say App2/Start.aspx?sessionID=123546789.

App2/Start.aspx in it's form_load uses the sessionID and and the
HTTPWebRequest class to hit a private page or even a simple WebService
hosted in LoginApp, which returns the user data (username and password) to
App2.

David
Nov 15 '05 #6
Fascinating. Does this method (passing a sessionID from 1 app to another)
have advantages / disadvantages over serializing the entire class & passing
it over -- the method that Nicholas outlined.

Also, if the first application is no longer there since we redirected them
with a URL, is that 123456789 session still in existence? In other words if
the 2nd app calls a page now in the Login app, how can it get a hold of that
prior session after we had already redirected away from that first app, in
order to get to the 2nd ;)
TY for enlightening the blind
Jason Shohet
Nov 15 '05 #7

" Jason Shohet" <as****@hotmail.com> wrote in message
news:uW****************@TK2MSFTNGP12.phx.gbl...
Fascinating. Does this method (passing a sessionID from 1 app to another)
have advantages / disadvantages over serializing the entire class & passing it over -- the method that Nicholas outlined.

No.
Also, if the first application is no longer there since we redirected them
with a URL, is that 123456789 session still in existence? In other words if the 2nd app calls a page now in the Login app, how can it get a hold of that prior session after we had already redirected away from that first app, in
order to get to the 2nd ;)

You would be in charge of storing the user info in a static or
application-scope HashTable, keyed by the session ID.

David
Nov 15 '05 #8
Thanks for the help Dave.
I think we're going to go with the serialization approach because then we
don't have to be in the business of storing sessions in a db table. We'll
serialize the class, & send it over in a POST.
The 2nd app can just reconstitute the class from the serialized string...
well at least it sounds good in theory :) !
Rgds
Jason Shohet
Nov 15 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: StephenMcC | last post by:
Hi All, Got a quick query in relation to the Server.Transfer method available in IIS 5+/ASP. I've got an issue where I want to take a portion of an online app and extract this out into a web...
1
by: Zhongqi Pan | last post by:
I am facing a problem- I am using f1(this) to pass a class object pointer to a function ( say f1) f1 is defined as follows
3
by: Justin | last post by:
Hi, Im confused here over the usage of Response.Redirect and Server.Transfer. I used frameset for my work, what are the proper usages of the two methods that seems working similar.. The...
2
by: ndario | last post by:
i am trying to transfer a user to another page with Server.Transfer() but i am having a problem with sending query params like this Server.Transfer("newPage.aspx?param=value"); in the PageLoad...
8
by: daberelay | last post by:
Hi, I'm using IHttpModule class (added to GAC and machine.config) to get requests of non existing pages in my web server and redirect them to different pages, using the...
4
by: Brian | last post by:
Hi, I'm trying to make an online FTP utility in C# ASP.NET using MSINET.ocx (an active X control a.k.a. "Microsoft Internet Transfer Control") I've added the reference into my project and have...
3
by: Steve Lutz | last post by:
Hello All, I have an ASPX page whose class inherits from a company global base page. The company base page has a property call PageTitle (string) that is assigned by all the pages. The base...
8
by: bryan | last post by:
I've got a custom HttpHandler to process all requests for a given extension. It gets invoked OK, but if I try to do a Server.Transfer I get an HttpException. A Response.Redirect works, but I really...
4
by: Andrew Jackson | last post by:
I am writing a newsgroup client. I have the protocol figured out. But I get slow transfer speeds off any of the network objects read the data from For example one of the commands for a news...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.