ASP.NET跨页面传值技巧总结
1.使用QueryString变量
QueryString是一种非常简单的传值方式,他可以将传送的值显示在浏览器的地址栏中。如果是传递一个或多个安全性要求不高或是结构简单的数值时,可以使用这个方法。但是对于传递数组或对象的话,就不能用这个方法了。下面是一个例子:
a.aspx.cs的C#代码
view plaincopy to clipboardprint?
private void Button1_Click(object sender, System.EventArgs e)
{
string s_url;
s_url = "b.aspx?name=" + Label1.Text;
Response.Redirect(s_url);
}
private void Button1_Click(object sender, System.EventArgs e)
{
string s_url;
s_url = "b.aspx?name=" + Label1.Text;
Response.Redirect(s_url);
}
b.aspx.cs中C#代码
view plaincopy to clipboardprint?
private void Page_Load(object sender, EventArgs e)
{
Label2.Text = Request.QueryString["name"];
}
private void Page_Load(object sender, EventArgs e)
{
Label2.Text = Request.QueryString["name"];
}
2.使用Application 对象变量
Application对象的作用范围是整个全局,也就是说对所有用户都有效。其常用的方法用Lock和UnLock。
a.aspx.cs的C#代码
view plaincopy to clipboardprint?
private void Button1_Click(object sender, System.EventArgs e)
{
Application["name"] = Label1.Text;
相关文档:
在Web编程过程中,存在着很多安全隐患。比如在以前的ASP版本中,Cookie为访问者和编程者都提供了方便,并没有提供加密的功能。打开IE浏览器,选择“工具”菜单里的“Internet选项”,然后在弹出的对话框里单击“设置”按钮,选择“查看文件”按钮,在弹出的窗口中,就会显示硬盘里 ......
发布中遇到了两个问题
一。session 会短时间自动消失
解决办法
1。在www.google.com中查session 丢失
2。在Window服务中将ASP.NET State Service 启动。
3。修改web.config
<system.web>
add <sessionState mode="StateServer" timeout="60"/>
二。sql server 超过最大连接池数
......
200X年12月23日的一次面试经历(共六轮),至此9-X周年之际,和各位朋友分享,希望对各位朋友有用,有些自己的答案贴出来也仅仅是抛砖引玉,希望各位朋友不吝赐教,说句老实话,面试的时候时间很紧,很难考虑最优算法。
起因是朋友推荐我去W公司应聘Senior SDE这个职位,应该算是内部推荐了,下面是招聘要求
Title: Senio ......
这几天学习使用WebPart,发现众多问题,使用点滴记录如下,同各位共享:
1、WebPart的使用必须基于一个通过身份验证的用户会话。
2、WebPart的使用的个性化应用于所有人的选项默认是禁用的,可以通过修改Web.config来完成
<webParts>
<personalization>
&nb ......
If you come to ASP.NET MVC from a purely ASP.NET Web Forms background, one of the first things you are likely to notice is that all those nice easy Server Controls have disappeared. One of those is the FileUpload, and its absence seems to cause a few problems. This article looks at how to upload f ......