前台代码:
<a href="" id="n6">会员设置</a>
<script language="javascript" type="text/javascript">$("#n6").click(function(){
$.post("getsession.aspx",function(session){alert("fd");
alert(session);
});
});
</script>getsession.aspx :
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;public partial class UserControl_getsession : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(Session["username"]); }
}为什么如此设置之后都没有反应呢?
<a href="" id="n6">会员设置</a>
<script language="javascript" type="text/javascript">$("#n6").click(function(){
$.post("getsession.aspx",function(session){alert("fd");
alert(session);
});
});
</script>getsession.aspx :
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;public partial class UserControl_getsession : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(Session["username"]); }
}为什么如此设置之后都没有反应呢?
解决方案 »
- asp.net中用程序根据表名获得表中字段的名字
- dll 文件反编辑 再生成dll 文件
- 关于VS.NET 2008的安装问题
- 请问在asp.net中如何读取Cookie文件
- 100分求<%#..%>出错的原因
- 怎样为1个添加到工程中的“Web用户控件”改名
- 请问framework1.0 和framword1.1中的system.drawing是不是有区别?
- 请问,在WEBFORM中,如何将Word文档的内容读入Web页面的指定的控件中,如textbox1,textbox2,送上100分!!!!!!!
- asp.net jquery
- 请问做URL重写的时候是否可以连网站地址一起覆盖重写掉?
- 在51aspx下载代码的问题
- 跪求解决方案:提示此计算机上没有安装项目系统组件重新安装vs2005
去使用asp.net ajax的UpdatePanel吧!或者干脆放弃Session。
Inherits="Pages_Office_StorageManager_TestJqureySession1" %><!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></title> <script src="../../../js/JQuery/jquery_last.js" type="text/javascript"></script> <script language="javascript" type="text/javascript">
$(document).ready(function() {
// Your code here... $("#n6").click(function() {
alert('a');
$.post("TestJqureySession.aspx", function(session) {
alert(session);
document.getElementById('div1').innerHTML = session;
}); });
});
</script></head>
<body>
<form id="form1" runat="server">
<div>
<input id="n6" type="button" value="Test" />
<div id="div1"></div>
</div>
</form>
</body>
</html>
另一个测试页面的后台:using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;public partial class Pages_Office_StorageManager_TestJqureySession : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string test = "我只是测试而已Test";
Session["test"] = test;
Response.Write(Session["Test"].ToString());
}
}
=====================ASP.Net_SessionID 这个 HTTP Header 对于同一Domain发送的请求都是带了的,你没取到应该是服务端的问题,试试用HttpFox监听一下链接,看此头是否发送过去了。 你的服务端使用的是HttpHandler?
后台Response.ClearContent();
Response.Write(Session["username"].ToString());
Response.End();
另外你不必Response.Cache.SetCacheability(HttpCacheability.NoCache);可以用$.ajax()设置cache:false参数
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
Session["pi"] = "中国人民银行";
}
</script>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="~/WebService.asmx" />
</Services>
</asp:ScriptManager>
<span onclick="WebService.HelloWorld(function(result){alert(result);});">Click Me</span>
</form>
</body>
</html>可见,直接调用web service就可以了。而这个web service则只是:<%@ WebService Language="C#" CodeBehind="~/App_Code/WebService.cs" Class="WebService" %>using System.Web.Services;[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService { [WebMethod(EnableSession=true)]
public string HelloWorld() {
return Session["pi"] as string;
}
}
1.最近在用Linq to Entity,哇塞,相比以前的SQL数据库编程和js编程效率提高的可不仅一倍。。
你对Linq to Entity评价怎么样?
2.在.net的微软企业库中,AOP处理异常,缓存,日志等东西,可经常用?
<script language="javascript" type="text/javascript">$("#n6").click(function(){
$.post("getsession.aspx?test=go",function(session){alert("fd");
alert(session);
});});
</script>getsession.aspx :
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;public partial class UserControl_getsession : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(Request.QueryString["test"] == "go")
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(Session["username"].ToString()); //得保证这个Session["username"]有值
}
else
{
Response.Write("请求失败。。");
}}
}
因为我用在Linq发布之前就自己写ORM系统,后来Linq发布终于解决了我一个一直没有很好解决的通用查询机制问题,所以我对Linq to xxxx 都包装成实现我的接口的东西。在帖子
http://topic.csdn.net/u/20100312/11/c5b51fa3-f1e7-4c46-aa74-14aad1cf1a0e.html?31209
17楼我介绍了我的接口规格。从我期望的角度,Linq to Entity应用起来似乎还是太复杂了。微软企业库我从来不用。但是HttpRuntime.Cache我经常用。AOP过于随意。实际上我们可以自定义事件,或者使用INotifyPropertyChanged、INotifyPropertyChanged等等方法来在设计时明明白白地告诉别人我们的架构欢迎别人来注入监听机制,这样可以预知被人修改后的后果。而不需要隐式支持危险的AOP。日志在测试时经常使用,测试完就可以关闭。这几乎没有什么好说的。是非常必须的东西。但是实现方法可以不一。我有时候仅写一行代码 File.AppendAllText(file,content) 就记录日志了。