C#中string 问题
代码如下,想输出+ GetstringIpAddress("string strIP"),也就是IP所查询的地址用的youdao. IP地址我在上面public string GetIP()已经获取,我想在下面的public static string GetstringIpAddress(string strIP)里写上一句strIP=GetIP()所获取的IP如何写
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Net;
using System.Net.Mail;
using System.IO;
using System.Xml;
public partial class _Default : System.Web.UI.Page
{
public SqlConnection conn;
protected void Page_Load(object sender, EventArgs e)
{
string sConnectionString = @"server=1-IO57X7TLRRVDX;database=shhr;user id=sa;password=111111;";
string sSql = "insert into IP(ip,DateTime,area) values('" + GetIP() + "',getdate(),'" + GetstringIpAddress("string strIP") + "')";
SqlConnection conn = new SqlConnection();
conn.ConnectionString = sConnectionString;
SqlCommand cmd = new SqlCommand();
cmd.CommandText = sSql;
cmd.Connection = conn;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
public string GetIP()
{
string result = String.Empty;
result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(result))
{
result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
if (string.IsNullOrEmpty(result))
{
result = HttpContext.Current.Request.UserHostAddress;
}
if (string.IsNullOrEmpty(result))
{
return "127.0.0.1";
}
return result;
}
public&