如何在不使用 Session 的情况下跨 ASP.net 中的页面传递值 [英] How to pass values across the pages in ASP.net without using Session

查看:23
本文介绍了如何在不使用 Session 的情况下跨 ASP.net 中的页面传递值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力提高我的门户网站的性能.我正在使用 Session 来存储状态信息.

I am trying to improve performance of my web portal. I'm using Session to store state information.

但我听说使用 session 会降低应用程序的速度.有没有其他方法可以在 asp.net 中跨页面传递值.

But I heard that using session will decrease the speed of the application. Is there any other way to pass values across the page in asp.net.

推荐答案

您可以通过以下方式将值从一个页面传递到另一个页面..

You can pass values from one page to another by followings..

Response.Redirect
Cookies
Application Variables
HttpContext

响应.重定向

设置:

Response.Redirect("Defaultaspx?Name=Pandian");

获取:

string Name = Request.QueryString["Name"];

Cookies

设置:

HttpCookie cookName = new HttpCookie("Name");
cookName.Value = "Pandian"; 

获取:

string name = Request.Cookies["Name"].Value;

应用变量

设置:

Application["Name"] = "pandian";

获取:

string Name = Application["Name"].ToString();

在此处参考完整内容:将值从一个传递到另一个

这篇关于如何在不使用 Session 的情况下跨 ASP.net 中的页面传递值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆