我在允许表单加载第二个表单时遇到问题。我正在尝试设置一个auth服务器:在一个名为Form2的表单上。如果验证码正确,则编程,以转到MainForm。所以我希望它显示“禁用身份验证代码”以关闭Form2并加载MainForm。这是Form2的代码(带有身份验证服务器代码的表单)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Diagnostics;
using System.Threading;
using System.IO;
using System.Net;
using System.Security.Cryptography;
namespace BBP
{
public partial class auth : Form
{
public static String Auth = null;
public static String Authcode = null;
public static String ip = null;
public auth()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
{
Auth = textBox1.Text;
if (Auth == (""))
{
MessageBox.Show("Enter Auth Code");
}
else
if (webBrowser3.Document.Body.InnerText.Contains(textBox1.Text))
MessageBox.Show("Auth Code Disabled");
else
if (webBrowser1.Document.Body.InnerText.Contains(textBox1.Text))
{
this.Hide();
Form2 f2 = new Form2();
f2.ShowDialog();
Application.Exit();
}
else
if (webBrowser2.Document.Body.InnerText.Contains(textBox1.Text))
{
this.Hide();
Form2 f3 = new Form2();
f3.ShowDialog();
Application.Exit();
}
else
{
MessageBox.Show("Invalid Auth Code");
}
}}
private void webBrowser1_DocumentCompleted(object sender,WebBrowserDocumentCompletedEventArgs e)
{
}
}
}
答案 0 :(得分:0)
关闭'Application.Exit()'行,然后重试。在说:退出应用程序之后,您无法打开表单。