abbott_2024_event/BackEnd/Login.aspx.cs

44 lines
1.1 KiB
C#

using Dapper;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace abbott_2024_event.BackEnd
{
public partial class Login : System.Web.UI.Page
{
SqlConnection conn = new SqlConnection(globalClass.appsettings("DBConnectionString"));
protected void Page_Load(object sender, EventArgs e)
{
string myIP = globalClass.GetIPAddress();
if (myIP == "::1")
{
myIP = "127.0.0.1";
}
Boolean isAllow = false;
if (myIP == "127.0.0.1")
{
isAllow = true;
}
ipTable ipTable = conn.QueryFirstOrDefault<ipTable>("select * from ipTable where ipTable_address = @ipTable_address", new { ipTable_address = myIP });
if (ipTable != null) {
isAllow = true;
}
if (isAllow == false)
{
Response.Redirect("auth-error-v3.html");
return;
}
}
}
}