1. Add the following element to web.config (you probably already have it in comment):
<Authentication Mode="Main" Type="YourNamespace.YourLogonForm, YourAssembly" />
2. Implement the logon form. When you want to specify that user has successfully authenticated just set IsLoggedOn property of the current session to 'true': this.Session.IsLoggedOn = true;
3. If you want a "logout" button or link, add it (link or button) and on it click event set the same property to false: this.Session.IsLoggedOn = false;
In general, I would recommend that you try to avoid using Redirect method inside VWG application. It is not best practice. Each VWG application has at least one entry point. When you navigate in your browser to URL that is mapped to an entry point (the mapping is in web.config via Application elements) it's like you "open" a new instance of a desktop application. In your case, if you'll redirect to "login.aspx" that’s mean that you mapped this URL to some form, probably: <ApplicationCode="login"Type="MyApplication.LoginForm, MyApplication "/>. So what you are actually doing is creating new VWG context (which is the equivalent to opening new instance of your application).
We're familiar with the need of developers to "replace" the current form with other form, usually it's for implementing logon screen. That why we added way back the authentication support in web.config.
But there are also other cases that suites this solution. So it’s a good opportunity to announce one of our new features to our next release (5.83): new method will be added to Gizmox.WebGUI.Forms. Form: Form.Transfer(Form formToReplaceWith). This method receives instance of the form you want to replace with. For example:
HttpSessionState aSession = this.Context.HttpContext.Session;
if ((aSession["userid"] == null) || ((int)aSession["userid"] < 1))
{
LoginForm form = new LoginForm();
this.Transfer(form);
}
Regards,
Tamir