WebBrowser 컨트롤 사용시 이전 세션때문에 문제가 생길때가 있습니다.
예를 들어 이전 WebBrowser 컨트롤을 써서 구글 로그인을 시킨 후 로그 아웃을 하지 않고 프로그램을 종료 후 다시 실행시키면,
전에 사용하던 세션이 남아 있어서 구글 계정이 자동으로 로그인이 되어있습니다.
세션을 초기화 시키면, 로그인 정보가 사라져서 로그인이 되어 있지 않습니다.
Program.cs
public class Form : Form
{
private const int INTERNET_OPTION_END_BROWSER_SESSION = 42;
[System.Runtime.InteropServices.DllImport("wininet.dll", SetLastError = true)]
private static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr IpBuffer, int IpdwBufferLength);
public void Init()
{
InternetSetOption(IntPtr.Zero, INTERNET_OPTION_END_BROWSER_SESSION, IntPtr.Zero, 0);
webBrowser1.Document.Window.Navigate(url);
}
}
'프로그래밍 > .NET' 카테고리의 다른 글
| [C#]string to HtmlDocument (Html Agility Pack) (0) | 2013.02.20 |
|---|---|
| [C#]CSV파일 읽기 (0) | 2013.02.19 |
| [C#]메일 전송(SMTP) (0) | 2013.02.12 |
| [C#]대리자 Func<> / Action<> (0) | 2013.02.10 |
| [C#]Delegate (0) | 2013.02.10 |