保持asp.net页面的状态

时间:2020-12-03 04:04:21

Am new to asp.net

我是asp.net的新手

Here is what I need to do: I've an asp.net page called Results.aspx which has got 8 AJAX collapsible panels and a gridview control binded to database.It also has pagination functionality.

这是我需要做的:我有一个名为Results.aspx的asp.net页面,它有8个AJAX可折叠面板和一个绑定到数据库的gridview控件。它还具有分页功能。

From this page, user can navigate to other pages in the application.When he comes back to Results.aspx,I need to persist states of the following areas: 1.All collapsible panels 2.Gridview control 3.Pagination

在此页面中,用户可以导航到应用程序中的其他页面。当他回到Results.aspx时,我需要坚持以下几个方面的状态:1。所有可折叠面板2.Gridview控件3.Pagination

What is the most efficient way of achieving this in asp.net other then using asp.net sessions?

除了使用asp.net会话之外,在asp.net中实现此目的的最有效方法是什么?

3 个解决方案

#1


ASP.NET Session is the most efficient way of doing this. You are harnessing a built-in, session-specific, user-specific state manager that is very fast and optimized to do exactly what you want to do. In this particular instance I would suggest that you store the metadata required to persist the user's settings in session (don't use session as a ViewState-replacement into which you cram whole controls). If you use session responsibly then I think you will find it suits your needs.

ASP.NET Session是最有效的方法。您正在利用内置的,特定于会话的,特定于用户的状态管理器,该管理器非常快速且经过优化,可以完全按照您的要求执行操作。在这个特定的实例中,我建议您存储在会话中持久保存用户设置所需的元数据(不要将会话用作您将整个控件填入其中的ViewState替换)。如果您负责任地使用会话,那么我认为您会发现它适合您的需求。

You could definitely do it other ways but why would you want to?

你绝对可以通过其他方式做到这一点但你为什么要这样做?

#2


Session State is the option, but beware how you implement that if you have a Server Farm or you are planning to escale your application.

会话状态是可选的,但要注意如果您有服务器场或者计划对应用程序进行扩展,请如何实现。

Regards!!!

#3


Using ASP.NET session state is about as efficient as you're going to get with this. You can use a custom session state provider if you feel the normal one is wrong for you, but it's pretty much the only way to persist the state of a page when you're on another page.

使用ASP.NET会话状态与您将要获得的效率一样高效。如果您认为正常的会话状态提供程序错误,则可以使用自定义会话状态提供程序,但这是在您处于其他页面时保持页面状态的唯一方法。

I suppose the other thing you could do is persist the state in a hidden field, then somehow post that to all the other pages you might possibly use after that.

我想你可以做的另一件事就是将状态保存在隐藏的字段中,然后以某种方式将其发布到之后您可能使用的所有其他页面。


The ASP.NET Cache object keeps information for the entire application - it is not per-user, so it would be a very bad way to persist per-page-per-user state.

ASP.NET Cache对象保留整个应用程序的信息 - 它不是每个用户的,因此这是一种非常糟糕的方法来保持每页用户的状态。

#1


ASP.NET Session is the most efficient way of doing this. You are harnessing a built-in, session-specific, user-specific state manager that is very fast and optimized to do exactly what you want to do. In this particular instance I would suggest that you store the metadata required to persist the user's settings in session (don't use session as a ViewState-replacement into which you cram whole controls). If you use session responsibly then I think you will find it suits your needs.

ASP.NET Session是最有效的方法。您正在利用内置的,特定于会话的,特定于用户的状态管理器,该管理器非常快速且经过优化,可以完全按照您的要求执行操作。在这个特定的实例中,我建议您存储在会话中持久保存用户设置所需的元数据(不要将会话用作您将整个控件填入其中的ViewState替换)。如果您负责任地使用会话,那么我认为您会发现它适合您的需求。

You could definitely do it other ways but why would you want to?

你绝对可以通过其他方式做到这一点但你为什么要这样做?

#2


Session State is the option, but beware how you implement that if you have a Server Farm or you are planning to escale your application.

会话状态是可选的,但要注意如果您有服务器场或者计划对应用程序进行扩展,请如何实现。

Regards!!!

#3


Using ASP.NET session state is about as efficient as you're going to get with this. You can use a custom session state provider if you feel the normal one is wrong for you, but it's pretty much the only way to persist the state of a page when you're on another page.

使用ASP.NET会话状态与您将要获得的效率一样高效。如果您认为正常的会话状态提供程序错误,则可以使用自定义会话状态提供程序,但这是在您处于其他页面时保持页面状态的唯一方法。

I suppose the other thing you could do is persist the state in a hidden field, then somehow post that to all the other pages you might possibly use after that.

我想你可以做的另一件事就是将状态保存在隐藏的字段中,然后以某种方式将其发布到之后您可能使用的所有其他页面。


The ASP.NET Cache object keeps information for the entire application - it is not per-user, so it would be a very bad way to persist per-page-per-user state.

ASP.NET Cache对象保留整个应用程序的信息 - 它不是每个用户的,因此这是一种非常糟糕的方法来保持每页用户的状态。