PDA

View Full Version : How to apply Spring.NETAOP to ASP.NET Web Application?


hawkclj
05-30-2006, 10:00 AM
recently,i research the Spring.NET AOP !fortunately,there are some simple samples!when i try to apply Spring.NET AOP to ASP.NET Web Application,i find difficulty.if you want use Advice to check user's Session which generates at login page:
First you must make the page implements a interface, in the interface there are a method Page_Load(object sender, System.EventArgs e).
Then you must implement IMethodBeforeAdvice,but i can't directly check Session,because Session can't exist in class library file(.cs file)
last you must use a .cs file to compose them.
but .cs file can not be the first start page in ASP.NET Web Application
can some people give me some advice to apply Spring.NET AOP to ASP.NET Web Application
thanks

Bruno Baia
05-30-2006, 08:31 PM
Hi,

Spring.Net AOP should be apply on PONOs (Plain Old .Net Objects).
It's not approriate for web page.

Don't know exactly what you want to do, but if you have a service that returns the user's information, you can apply your aspects there.
To access Session everywhere, you can use

System.Web.HttpContext.Current.Session

but you can't be sure when Session exists.


-Bruno

hawkclj
05-31-2006, 04:05 AM
i want to apply Spring.NET AOP to AccessControl in ASP.NET Web Application.
when user login the page,i intercepter this and add Advice to implement AccessControl.
do you think it's possible,and what's the best solution?
thank you very much:)

Aleks Seovic
06-11-2006, 07:33 AM
Technically, you should be able to proxy Spring-managed web pages by advising IHttpHandler interface and its ProcessRequest method. Please take a look at the reference documentation on how to configure AOP proxy using specific interface, and make sure that your *proxy* definition has an object id that matches the name of the page in the request URL. This will ensure that call to ProcessRequest goes through AOP proxy before it gets to the page. I'm not 100% sure this will work (there might be some issues related to session management, as Bruno mentioned), but it's probably worth a try.

Finally, why an angry message? We are all just trying to help...

Regards,

Aleks

hawkclj
06-11-2006, 02:57 PM
sorry,i'm not angry,just a label!
thank you very much !
your help gives me too much !