你可以获取到的值remote_ip_info['city']赋值到页面的隐藏域中 然后在后台进行接收显示。代码如下:
前台代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
后台接收代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
Model.BankOperate _bank = new Model.BankOperate();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write(Request["remote_ip_info"].ToString());
}
}
显示的效果如下:
你可以增加一个中间页,例如 XX.aspx
JS是无法直接给后台赋值,但是你可以通过增加一个跳转来实现。
例如,你当前获取城市的JS页面叫做XX.aspx,而area页面叫做YY.aspx
在XX.aspx页面,使用window.location跳转,然后传递city参数