Forum  General Visual ...  How do I...?  How to override the Timeout.wgx page
Previous Previous
 
Next Next
New Post 3/21/2010 12:55 AM
  jimmyseow
54 posts
No Ranking


Re: How to override the Timeout.wgx page 

I have added AddHandler Application.ThreadExit, AddressOf HandleThreadExit to the Form Load of the MainForm.wgx. But it doesn't work. It seems to login to the application and then log back out immediately.

I can't find anything hat I did wrong. I have sent a sample of my application to support@visualwebgui.com. I am using visual webgui professional 1.1 build 6.3.13 for .net 3.5.

Regards

 
New Post 3/22/2010 2:56 PM
  palli
11824 posts
1st Level Poster




Re: How to override the Timeout.wgx page 

Hi Jimmy,

We received your application and I took a quick look.

First, two "words of wisdom" :-) By using Visual WebGui authentication mode you are actually requesting that if there is a request made from the client to the server, and the session does not have IsLoggedOn = True, then redirect that request to the Logon form you specify.

That means that you should not have a redirect in your Logon form processing, as the next request made from the client to the server after you set IsLoggedOn = True, it will pass the logon form and go directly to the requested destination form, MainForm.wgx in this case.

Second, you need to remember that you are attaching to an application level event when you attach to ThreadExit and in your case this fact, your extra redirect in the logon form and an unfortunate sequence of events makes your app behave like it does.

If you debug it and watch carefully what happens, you will see the Load event of your MainForm fire twice. My guess is that the first fires as this was the first request to the server after you set the IsLoggedOn = True and the second fires immediately after caused by your extra redirect.

The effect in your scenario is that when the second ThreadExit fires, you alrready attached your event handler to the ThreadExit event, and therefore you exit your application right away.

Just by commenting out the redirect from your Logon form processing (the LogonWebUser sub), you should be running quite fine.

Finally, are you sure you want to attach to the ThreadSuspend event like that ? Please take a look when the ThreadSuspend event fires on this wiki page here.

Hope this helps to get you on track again.

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 3/22/2010 9:31 PM
  jimmyseow
54 posts
No Ranking


Re: How to override the Timeout.wgx page 

Thanks for your insight.

I'm assuming you are referring to the line Me.Context.Redirect(FormsAuthentication.DefaultUrl). I actually copied this code from your sample code http://www.visualwebgui.com/Developers/Resources/Codes/tabid/326/ArticleType/ArticleView/ArticleID/109/PageID/104/Default.aspx

If it is wrong, somebody should correct the sample.

However, I ran into another problem. I am using the ASP.NET membership provider to authenticate. With the Me.Context.Redirect(FormsAuthentication.DefaultUrl) line, when I executed MainForm.wgx, Membership.GetUser contains the userid. So does HttpContext.Current.User.Identity.Name. When I comment out the Me.Context.Redirect, I no longer get the user id. Membership.GetUser returns nothing and HttpContext.Current.User.Identity.Name return an empty string. Should I save the userid in the session after I authenticate the user? Is that the best practice?

Also, I am confused about the ThreadSuspend subroutine. In your comments here http://www.visualwebgui.com/Developers/Forums/tabid/364/forumid/29/threadid/29876/postid/32052/threadpage/2/scope/posts/Default.aspx
You mentioned that

"The Terminate terminates the current Context, while the Abandon terminates the Session, which includes the current context, and there fore it also destroyes the context."

So, I thought by using Abandon, I can terminate the Context and Session together. Should I not be terminating the Session?

Thanks and Regards

 
New Post 3/23/2010 12:10 PM
  palli
11824 posts
1st Level Poster




Re: How to override the Timeout.wgx page 

Hi Jimmy,

This code sample is not supplied and maintained by Gizmox as far as I know. This is a user contributed sample, written for the version of Visual WebGui current at that point in time. If you confirm errors, I suggest you add comments to the article so users will know, and for the author to react if he/she is still available for updating the sample code.

The Redirect line is not necessarily wrong, you just have to know what effect it haves when used the way you do.

While I was testing your app, I think I tested moving the AddHandler line for the ThreadExit and make it the last line of your Form.Load event handler, then I think it did work the way you used it.

What I was refering to with my comment was not the usage of Abandon(). I was refering to is you intended to use the ThreadSuspend to log the user out, as then the user would be logged out if he refreshed the browser.

You are correct though about the Abandon() of the session, it will also destroy the Context, which is stored within the Session, somewhat like a session variable.

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
Previous Previous
 
Next Next
  Forum  General Visual ...  How do I...?  How to override the Timeout.wgx page
Assessment Bottom
.NET Web, Cloud and Mobile application delivery platform | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2011 Visual WebGui®       Visual WebGui weblog on ASP.NET Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS