|
Rank: Newbie Groups: Member
Joined: 11/5/2014 Posts: 8
|
Hi, I'm doing the following test: I created two buttons on the form. Each button opens a different form. Each form has a web view and webcontrol. test 1 When I start the program I click the button I click on button 1 and 2. When I open gmail in the webview and I log Form1, Form2 also automatically logs. They share the same session. test 2 If I open the program set up twice, and open a web view on each, they do not share the same session.
What changes should I make in the program code for the test1 it tab webview without two share the same login in gmail?
How do I create two webview in the same program without them share the same login in gmail?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
In order to prevent the two WebView from sharing sessions/cookies you need to create the two WebView in separate AppDomain. All WebView instance in the same AppDomain will always share cookie/session information.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 11/5/2014 Posts: 8
|
thaaannnnkkkkssss! its work.
Code: C#
public sealed class Isolated<T> : IDisposable where T : MarshalByRefObject
{
private AppDomain _domain;
private T _value;
public Isolated()
{
_domain = AppDomain.CreateDomain("Isolated:" + Guid.NewGuid(),
null, AppDomain.CurrentDomain.SetupInformation);
Type type = typeof(T);
_value = (T)_domain.CreateInstanceAndUnwrap(type.Assembly.FullName, type.FullName);
}
public T Value
{
get
{
return _value;
}
}
public void Dispose()
{
if (_domain != null)
{
AppDomain.Unload(_domain);
_domain = null;
}
}
}
Code: C#
using (Isolated<Form2> isolated = new Isolated<Form2>())
{
isolated.Value.ShowDialog();
}
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Great. Thanks for sharing! Glad to hear that it works!
|
|