I do a message when I think of doing so, the specific ideas may not be good, to make just a comment, hope that there is a better way!
IP Add page is a ListBox, TextBox, two button, while on other pages directly with the current IP comparison database IP, code as follows!
Restrict IP Add page HTML code
<%@ Page language= "C #" autoeventwireup= "true" codefile= "Ip.aspx.cs" inherits= "Admin_ip"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-TRANSITIONAL.DTD">
http://www.w3.org/1999/xhtml">
<title> Untitled Page </title>
<link href= ". /images/news.css "rel=" stylesheet "type=" Text/css "/>"
<body>
<form id= "Form1" runat= "Server" >
<div>
<asp:sqldatasource id= "SqlDataSource1" runat= "Server" connectionstring= "<%$ Connectionstrings:book"
Providername= "<%$ Connectionstrings:book. ProviderName%> "selectcommand=" SELECT [IP] from [IP] >
</asp:SqlDataSource>
<table align= "center" style= "border-right: #0066cc 1px dotted; Border-top: #0066cc 1px dotted; Border-left: #0066cc 1px dotted; Border-bottom: #0066cc 1px dotted ">
<tr>
<TD rowspan= "2" style= "width:100px; Border-right: #33ccff 1px groove; Border-top: #33ccff 1px groove; Border-left: #33ccff 1px groove; Border-bottom: #33ccff 1px groove; >
<asp:listbox id= "IPLXB" runat= "Server" datasourceid= "SqlDataSource1" datatextfield= "IP"
Datavaluefield= "IP" height= "194px" width= "153px" ></asp:ListBox></td>
<TD style= "width:100px; Border-right: #33ccff 1px groove; Border-top: #33ccff 1px groove; Border-left: #33ccff 1px groove; Border-bottom: #33ccff 1px groove; >
Fill in the standard IP address to the bottom left text box, and then click the button to add! <br/>
<asp:regularexpressionvalidator id= "RegularExpressionValidator1" runat= "Server" controltovalidate= "IPTB"
Display= "Dynamic" errormessage= IP address incorrectly formatted "validationexpression=" ([0-9]{2,3}) ([.]) ([0-9]{1,3}) ([.]) ([0-9]{1,3}) ([.]) ([0-9]{1,3}) "></asp:RegularExpressionValidator></td>
</tr>
<tr>
<TD style= "width:100px; Border-right: #33ccff 1px groove; Border-top: #33ccff 1px groove; Border-left: #33ccff 1px groove; Border-bottom: #33ccff 1px groove; >
<asp:linkbutton id= "LinkButton1" runat= "Server" onclick= "LinkButton1_Click" > Delete selected Rows </asp:LinkButton> </td>
</tr>
<tr>
<TD style= "width:100px; Border-right: #33ccff 1px groove; Border-top: #33ccff 1px groove; Border-left: #33ccff 1px groove; Border-bottom: #33ccff 1px groove; >
<asp:textbox id= "IPTB" runat= "Server" width= "150px" >61.139.33.22</asp:TextBox></td>
<TD style= "width:100px; Border-right: #33ccff 1px groove; Border-top: #33ccff 1px groove; Border-left: #33ccff 1px groove; Border-bottom: #33ccff 1px groove; >
<asp:button id= "Button1" runat= "Server" onclick= "Button1_Click" text= "Add" width= "80px"/></td>
</tr>
</table>
</div>
</form>
</body>
Limit IP Add page CS code
Using System;
Using System.Data;
Using System.Configuration;
Using System.Collections;
Using System.Web;
Using System.Web.Security;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.WebControls.WebParts;
Using System.Web.UI.HtmlControls;
public partial class Admin_ip:System.Web.UI.Page
{
protected void Page_Load (object sender, EventArgs e)
{
Server.Execute ("chklog.aspx");
}
protected void Button1_Click (object sender, EventArgs e)
{
Iplxb. Items.Add (IPTB. Text);
Odb.insert (INSERT into IP (IP) VALUES (' + IPTB. Text + "')");
}
protected void LinkButton1_Click (object sender, EventArgs e)
{
for (int i = 0; i < IPLXB. Items.Count; i++)
{
if (IPLXB. Items[i]. Selected)
{
Odb.insert ("Delete from IP where ip= '" +IPLXB.) selecteditem.text+ "'");
Iplxb. Items.remove (IPLXB. Selecteditem.text);
}
}
}
}
Code for Page Call page that is required to restrict IP
protected void Page_Load (object sender, EventArgs e)
{
String ip = Request.UserHostAddress.ToString ();
if (Convert.ToInt32 (ODB.SCR () SELECT count ( * FROM [IP] where ip= ' "+ IP +" ' ") > 0)
respo Nse. Write ("Sorry, your IP is restricted access, please consult the Administrator");
}
}