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

标签 c# asp.net

虽然从一个页面重定向到另一个页面,但我通常将值作为查询字符串传递,但正如您所知,查询字符串不是一个好方法,因为存在许多安全问题,而且它的最大大小为 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/

相关文章:

c# - 如何在类中初始化不可为空的字符串?

c# - REST Api 为同一对象返回不同的对象名称,如何使用 RestSharp 处理?

.net - 需要帮助理解 TreeNodeCollection 的 .Net Collection 行为

asp.net - 在asp.net中获取Facebook Page Feed(使用graph api),收到错误 "Unsupported Browser"

asp.net - ASP.NET 中的 HttpHandler 是什么

asp.net - 正则表达式中的 "(?i)"是什么意思?

c# - 即使使用 ConfigureAwait(false),在 WebAPI 中同步调用异步方法也会死锁

c# - 无法从另一个类访问列表

c# - 自托管WCF服务: ConcurrencyMode.多个但仅使用一个线程?

c# - 在 ASP.NET 中删除 session 结束时的临时文件