gpt4 book ai didi

c# - Asp.Net,从上一页访问变量是一种好方法吗?

转载 作者:太空宇宙 更新时间:2023-11-03 17:04:14 26 4
gpt4 key购买 nike

虽然从一个页面重定向到另一个页面,但我通常将值作为查询字符串传递,但正如您所知,查询字符串不是一个好方法,因为存在许多安全问题,而且它的最大大小为 256 字节,即长度为 2048人物。那么通过设置上一页即"<%@ PreviousPageType VirtualPath="" %>"来访问变量是一种好方法吗?并访问以前的页面项目

请告诉我,除了 Sessions 之外,还有其他方法可以传递变量吗?并且使用上一页概念是一种好方法吗?

最佳答案

这里来自 MSDN 的 How to: Pass Values Between ASP.NET Web Pages :

You can pass information between pages in various ways, some of which depend on how the redirection occurs. The following options are available even if the source page is in a different ASP.NET Web application from the target page, or if the source page is not an ASP.NET Web page:

  • Use a query string.
  • Get HTTP POST information from the source page.

The following options are available only when the source and target pages are in the same ASP.NET Web application.

  • Use session state.
  • Create public properties in the source page and access the property values in the target page.
  • Get control information in the target page from controls in the source page.

因此假设您拥有相同的 ASP.NET 应用程序 PreviousPage 属性正是为您的案例设计的。

关于c# - Asp.Net,从上一页访问变量是一种好方法吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8767571/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com