高分求教一小段代码
小弟有段代码这样的
login.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="login.aspx.vb" Inherits="login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Login Page</title>
</head>
<body style="font-family: Arial, Helvetica, sans-serif; font-size: 10pt; font-weight: normal; font-style: normal; font-variant: normal">
<form id="form1" runat="server">
<div>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr style="height: 100px">
<td >
</td>
<td style="width: 290px;" align="center" valign="bottom" >
<font color="#ff0000" style="font-size: 11pt">>>> For Authorized Access Only <<<</font>
</td>
<td >
</td>
</tr>
<tr>
<td style="width: 25%; height: 131px;">
</td>
<td align="center" style="width: 290px; height: 131px;">
<br />
<asp:Login ID="Login1" runat="server" BackColor="#EFF3FB" BorderColor="#B5C7DE" BorderPadding="4" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" ForeColor="#333333" DestinationPageUrl="home.aspx" DisplayRememberMe="False" Width="100%" LoginButtonText="Log In 秈" TitleText="Log In (L.A.)">
<TitleTextStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" Font-Overline="False" Font-Size="13pt" />
<InstructionTextStyle Font-Italic="True" ForeColor="Black" />
<TextBoxStyle Font-Names="Verdana" Font-Underline="False" Font-Size="10pt" />
<LoginButtonStyle BackColor="#C0FFFF" BorderColor="#507CD1" BorderStyle="Solid" BorderWidth="1px"
Font-Names="Verdana" Font-Size="10pt" ForeColor="#284E98" />
<LabelStyle Font-Names="Verdana" Font-Size="10pt" />
</asp:Login>
</td>
<td style="width: 25%; height: 131px;">
</td>
</tr>
<tr>
<td style="width: 25%; height: 131px">
</td>
<td align="center" style="width: 290px; height: 131px; text-align: left;"
valign="top">
</td>
<td style="width: 25%; height: 131px">
</td>
</tr>
</table>
<br />
</div>
</form>
</body>
</html>
dim strIP as string=Request.ServerVariables("REMOTE_ADDR")
dim sw as system.io.streamWriter("log.log")
sw.WriteLine("IP:{0},Time:{1}", strIP, datetime.now.tostring("yyyy-MM-dd HH:mm:ss")
sw.close()
Login1.DestinationPageUrl = "BBS/bbs.aspx?opt=bbs"
End Sub
End Class
大概这样,没测试,你试试
[解决办法]Using sw As New StreamWriter(Server.MapPath("log.txt"), True, System.Text.Encoding.UTF8, 4096)
sw.WriteLine("IP:{0},Time:{1}", Request.ServerVariables("REMOTE_ADDR"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
End Using
Login1.DestinationPageUrl = "BBS/bbs.aspx?opt=bbs"
[解决办法]
Dim IPAdress As System.Net.IPAddressHostName = System.Net.Dns.GetHostName '获得本机的机器名
IPAdress = System.Net.Dns.GetHostByName(HostName).AddressList.GetValue(0) '获得本机的IPMe.TextBox1.Text = HostName '本机机器名
Me.TextBox2.Text = IPAdress.ToString '本机的IP
然后把得到的ip地址 带入记录日志类里面就可以了
代码就不发了 可以参考网上的日志类
http://blog.csdn.net/inrgs/article/details/1493322
[解决办法]