473,756 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1433
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.co m

" Jason Shohet" <as****@hotmail .com> wrote in message
news:uH******** *****@TK2MSFTNG P10.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******** *****@TK2MSFTNG P10.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******** *****@TK2MSFTNG P10.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******** **********@tk2m sftngp13.phx.gb l...
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?sess ionID=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******** ********@TK2MSF TNGP12.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
2238
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 site on its own, so I will end up having two web sites. This planned to aid problems we've been having with performance, as if the portion (which is an app in its own right) has problems we then have to restart the whole site and so bring everything...
1
2180
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
9080
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 problem i faced while using Response.Redirect is that the page that is directed to, does not looks as desired..the textboxes are not visible anymore and so as
2
2022
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 method of the newPage.aspx.cs, Request.QueryString is allways null. is there any way to transfer to another page, but to recive a param on the another page. i even try with response.redirect, but it doesn't help. also, puting value in the...
8
1655
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 Context.Server.Transfer(Target) method. i.e : Original ==> http://myserver/notExist/HelloThere to Target ==> http://myserver/DoesExist/helloWorld.aspx
4
3792
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 been able to compile it. However, when I go to a webpage, and try to FTP something, I get this error: System.Web.HttpUnhandledException was thrown.(Class is not licensed for use)
3
1952
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 class also includes a class that is used for logging. This logging class uses HttpContext.Current.Handler to get the instance of the page. In this way, it can get the PageTitle property.
8
3900
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 need to avoid the extra round-trip to the client. I've tried Passing the page name, the full URL, and the instance of the handler class to the Transfer method, but everything gets me the same error 500. Any help would be appreciated.
4
7584
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 client to use is "XOVER articlenumber-" This return string after string of all the news articles from article number on.... Another newsclient, i wont name names, pulls data down just fine. Using a
0
9455
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9271
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10031
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9869
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9838
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9708
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8709
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.