<html>
<head>
</head>
<body><a>
<script type="text/javascript"> window.open('http://localhost/search/search.html','found','width=300,height=200')
</script>
<html><body>
<div><p>用户名:<input type=text; style="width:160px"; id="username"; name="username"></input></p></div>
</body></html>
<?php
@session_start();
$_SESSION['name']=username;
?>按照上面的形式将session传到aspx.cs里 (text里会输入sa)public partial class search : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{ if (Session["name"].ToString() != "sa")
Response.Redirect("http://localhost/search/login.php");
else
Response.Write("session error");
}
catch (Exception exception)
{
Response.Write("data:" + exception.Message); }
}
}}
请问php页面传session到aspx.cs页面的时候是上面那种形式传么? 为什么我到aspx.cs页面的时候接收不到session,提示data:未将对象引用设置到对象的实例。
<head>
</head>
<body><a>
<script type="text/javascript"> window.open('http://localhost/search/search.html','found','width=300,height=200')
</script>
<html><body>
<div><p>用户名:<input type=text; style="width:160px"; id="username"; name="username"></input></p></div>
</body></html>
<?php
@session_start();
$_SESSION['name']=username;
?>按照上面的形式将session传到aspx.cs里 (text里会输入sa)public partial class search : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{ if (Session["name"].ToString() != "sa")
Response.Redirect("http://localhost/search/login.php");
else
Response.Write("session error");
}
catch (Exception exception)
{
Response.Write("data:" + exception.Message); }
}
}}
请问php页面传session到aspx.cs页面的时候是上面那种形式传么? 为什么我到aspx.cs页面的时候接收不到session,提示data:未将对象引用设置到对象的实例。
<body>
<div style=" border:1px #ddd solid; overflow:hidden;text-align:center; float:center; margin:100px;">
<div style="textalign=center; margin-top:10px; margin-left:auto">
<div><p>用户名:<input type='text'; style="width:160px"; id="username"; name="username"></input></p></div></a></body></html>
这样的aspx的话,那么在aspx.cs里如何写session["name"]?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="login1.aspx.cs" Inherits="login1" %>
<body><a>
<script type="text/javascript">
function $(id){
return document.getElementById(id);
}
window.onload = function(){$('username').focus();$('username').onkeydown = function(){
if(event.keyCode == 13){
$('password').select();
}
}
$('password').onkeydown = function(){
if(event.keyCode == 13){if(chklg())window.open('http://localhost/search/search.aspx','found','width=300,height=200')
}
}
}function chklg(){
if($('username').value != "sa"){
alert('用户名输入错误');
$('username').select();
return false;
}
if($('password').value != "sa"){
alert('密码输入错误');
$('password').select();
return false;
}
return true;
}function test(){if(chklg())
window.open('http://192.168.0.253/search/search.aspx','found','width=300,height=200')
}
</script>
<div style=" border:1px #ddd solid; overflow:hidden;text-align:center; float:center; margin:100px;">
<div style="textalign=center; margin-top:10px; margin-left:auto">
<div><p>用户名:<input type='text'; style="width:160px"; id="username"; name="username"></input></p></div><div id=usr></div>
</div>
<div style="position:relative; margin-top:10px; margin-left:auto;">
<div><p>密码: <input type="password"; style="width:160px"; id='password'; name='password'></input></p></div>
<div id=pwd></div>
</div><div style="margin-top:10px;margin-left:50px;"><input style="width:70px" type="submit"; value="登录" onclick="test()"></input></div>
</div>
</a></body></html>aspx.cs代码如下public partial class login1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["name"] = ???;
}
}
}上面aspx.cs代码如何写才能将session写对啊? 就是说跳转到下一个页面(http://localhost/search/search.aspx)的时候,用Session["name"] 得到session值啊?