Problem with principal using Ajax

Problem with principal using Ajax

Old forum URL: forums.lhotka.net/forums/t/4955.aspx


edika99 posted on Tuesday, June 10, 2008

I'm trying to use some ajax method to execute operation on the ProjectTrackerSample. I0ve notice a strange behaviour in the global.asax when calling Ajax method. The principal in the session is null so the ApplicationContext.User is reintiliazied to a null principal each time I use an ajax method.

There is a way to avoid this behaviour?

 

Thanks.

Edika

 

RockfordLhotka replied on Thursday, June 12, 2008

I don't know, but it sounds like Session may not be loaded yet in the event you are handling in global.asax. You may need to move the auth code to another event that fires later in the page load processing - after Session has been initialized.

Henrik replied on Thursday, June 12, 2008

Edika

I assume that you are calling an ASMX webservice.

In the global.asax you must restore the authenticated principal, from session state, as Rocky shows in the Project Tracker web sample application.

Furthermore you must enable session state in the service method. For ASMX services you do this by adding EnableSession:=True to the WebMethod attribute.

[Example]
<WebMethod(EnableSession:=True)> _
Public Function DoSomething() As String
 ...
End Function

Hope this helps.

Cheers
/Henrik

 

Copyright (c) Marimer LLC