简体   繁体   English

在 ASP.NET 页面中传递值

[英]Passing Value in ASP.NET Pages

I am developing a web application using asp.net and C#.我正在使用 asp.net 和 C# 开发 Web 应用程序。 I have a question我有个问题

Is there any way for passing values in asp pages without using QueryString or Session values or Cookies or previous page?有没有办法在不使用QueryStringSession值或Cookies或上一页的情况下在 asp 页面中传递值?

You may see: ASP.NET State Management Overview您可能会看到: ASP.NET 状态管理概述

Profile Properties配置文件属性

You can use: ASP.NET provides a feature called profile properties, which allows you to store user-specific data.您可以使用: ASP.NET 提供了一个称为配置文件属性的功能,它允许您存储用户特定的数据。 This feature is similar to session state, except that the profile data is not lost when a user's session expires.此功能类似于会话状态,不同之处在于,当用户会话过期时,配置文件数据不会丢失。 The profile-properties feature uses an ASP.NET profile, which is stored in a persistent format and associated with an individual user. profile-properties 功能使用 ASP.NET 配置文件,该配置文件以持久格式存储并与单个用户关联。 The ASP.NET profile allows you to easily manage user information without requiring you to create and maintain your own database. ASP.NET 配置文件允许您轻松管理用户信息,而无需您创建和维护自己的数据库。 In addition, the profile makes the user information available using a strongly typed API that you can access from anywhere in your application.此外,配置文件使用强类型 API 提供用户信息,您可以从应用程序的任何位置访问该 API。 You can store objects of any type in the profile.您可以在配置文件中存储任何类型的对象。 The ASP.NET profile feature provides a generic storage system that allows you to define and maintain almost any kind of data while still making the data available in a type-safe manner. ASP.NET 配置文件功能提供了一个通用存储系统,允许您定义和维护几乎任何类型的数据,同时仍然以类型安全的方式使数据可用。

您可以使用asp.net 缓存或将数据从一个页面保存到某个persistent medium而其他页面将从该介质中读取,可以是database or xm等。

Beside your requirements(not using QueryString or Session values or Cookies ) yes you can use public property like除了您的要求(不使用QueryStringSession值或Cookies )是的,您可以使用public属性,如

public String YourProperty
{
    get
    {
        return "Return What you want to pass";
    }
}

Check this MSDN article for full code查看此MSDN文章以获取完整代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM