Developer forum

Forum » Dynamicweb 9.0 Upgrade issues » DW 9.0.0.0 ExtranetLogOn throws "Samlingen blev ændret efter oprettelse af en forekomst af optælleren."

DW 9.0.0.0 ExtranetLogOn throws "Samlingen blev ændret efter oprettelse af en forekomst af optælleren."

Evaldas Raisutis
Reply

I've been trying to implement login functionality via a generic http handler, and after some struggling managed to get a user logged in, but then realized it was the wrong user. I cleared the cookies, hoping to try again and debug, but now I'm getting following exception.

[InvalidOperationException: Samlingen blev ændret efter oprettelse af en forekomst af optælleren.]
   System.Collections.Specialized.NameObjectKeysEnumerator.MoveNext() +8380284
   Dynamicweb.Environment.CookieManager.UpdateCookie(Cookie cookie) +452
   Dynamicweb.Frontend.LoginHandler.SaveCookie() +1732
   Dynamicweb.Frontend.LoginHandler.ExtranetLogin(String username, String password, Boolean onlyActive, Boolean impersonateUser, Int32 impersonateUserID, Boolean loginIfPwdEncrypted) +13357
   Dynamicweb.Frontend.LoginHandler.ExtranetLogOn(String username, String password) +36
   Hounisen.SingleSignOn.Security.Authentication.Login(String username, String password) in C:\inetpub\wwwroot\Hounisen\Hounisen.SingleSignOn\Security\Authentication.cs:16
   Hounisen.SingleSignOn.User.UserService.Login() in C:\inetpub\wwwroot\Hounisen\Hounisen.SingleSignOn\User\UserService.cs:60
   Hounisen.SingleSignOn.Generic.LoginHttpHandler.ProcessRequest(HttpContext context) in C:\inetpub\wwwroot\Hounisen\Hounisen.SingleSignOn\Generic\LoginHttpHandler.cs:51
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +798
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +91

What gives? I'm calling new PageView().Load(); at the beggining of HttpHandler before doing anything, and then using Dynamicweb.Frontend.LoginHandler.ExtranetLogOn


Replies

 
Evaldas Raisutis
Reply

I Seem to be able to replicate it if I call 

ExtranetLogOn(username, password); 

after clearing cookies (but without logging out); Also, after clearing cookies, LoginHandler.UserLoggedIn is equals to True. How? Why? 

 
Martin Vang
Martin Vang
Reply

Hi Evaldas,

My guess would be, that you're somehow removing keys from the cookie while you iterate the keys, by doing this in an async manner. It's only a guess, as I don't have the code or the version of DW you're using. :)

BR

Martin

 
Martin Vang
Martin Vang
Reply

Hi Evaldas,

That's because you havn't logged off... ?

You should use the API for both log on and log off.

BR

Martin

 
Evaldas Raisutis
Reply

Hi Martin,

Well no, I have no other code running modifying the cookie. Though I imagine if I run one tab to open the website, and another one to hit the HttpHandler, it could be an issue.

My problem is that I want to be able to change users. At the moment, if I use ExtranetLogOn to login with user A, and then change credentials to login as user B, LoginHandler.UserLoggedIn will still be true (even if I had cleared the cookies prior to calling HttpHandler again). Fair enough, I can just call LoginHandler.ExtranetLogoff() to log out with current user. But when I make the next call to HttpHandler, .UserLoggedIn is still True. If LoginHandler.ExtranetLogoff() is not for logging out, what should I use?

 
Evaldas Raisutis
Reply

I think I found out why .UserLoggedIn is always true before my code runs. I'm using username and password query strings to capture parameters. Appearently, dynamicweb will automaticly log a visitor in, if website url includes query strings username and passowrd. So for ex. webshop.dk?username=test&password=test will log user in as user "test". Since I used same query strings, DW would log user in before my code runs. 

 
Martin Vang
Martin Vang
Reply

Hi Evaldas,

If you call ExtranetLogoff, your current session is abandoned. So no, UserLoggedIn is false after calling this method. You most likely have autologin or something similar enabled.

BR

Martin

 

You must be logged in to post in the forum