会话变量问题 [英] Session variables problem

查看:64
本文介绍了会话变量问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了正确构建以下问题的方法(使用c#

asp.net): -


我的问题是如何最好从一个网页传递收集的数据

用于另一个网页。


我的问题是如何最好地从第一页传递搜索条件

到第二个。搜索条件作为结构存在,并在用户按下第一页上的搜索按钮时填写。


1.呈现收集用户搜索条件的asp页面

2.查询SQL后显示搜索结果网格


如果我使用会话来存储它,那么这会导致会话中的问题

变量会在用户的第二次搜索时被覆盖,但是在浏览器的后退按钮上按几下b / b
会让您进入预期的页面

会话中不同的标准从早些时候开始不再存在。


ViewState似乎不好,因为它只能用于回发和上面的问题

仍然会导致问题。


我不想在地址行中传递搜索条件,因为这是

凌乱并允许用户更改和查看它。


我相信你也可以使用Server.Transfer但我认为这会有一个

长期可用数据的类似问题。


任何关于正确方法的指示都是最受欢迎的。

I am having issues with the right way to architecture the following (using c#
asp.net):-

The question I have is how best pass the collected data from one web page
for use in another.

The question I have is how best pass the search criteria from the first page
to the second. The search criteria exists as a structure and is filled when
the user presses the ''Search'' button on the first page.

1. Present an asp page for collecting user search criteria
2. Show grid with results of search after querying SQL

If I use the session to store it, then this causes problems as the session
variable is overwritten on a second search by the user, but a couple of
presses on the back button of the browser will get you to a page expecting
different criteria in the session from earlier which is no longer there.

ViewState seems no good as it only works on postback and the above issue
would still cause a problem.

I do not want to pass the search criteria in the address line as this is
messy and allows the user to change and view it.

I beleive you can also use Server.Transfer but I think this would have a
similiar issue with the data being available long-term.

Any pointers as to the correct approach to this would be most welcome.

推荐答案

这样的页面的一个好方法是使用查询字符串。那个

方式的数据全部都包含在URL中,用户可以将这些数据加入书签

。这个URL确实有尺寸限制(2048

个字符,我想?)


-

Scott
http://www.OdeToCode.com/blogs/scott/


周三,2004年12月1日08:09:06 -0800,Simon Matthews

< Si ******** ***@discussions.microsoft.com>写道:
A good technique for pages like this is to use the query string. That
way the data is all contained in the URL and users can bookmark
favorite searches. The URL does have a size limitation though (2048
characters, I think?)

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Wed, 1 Dec 2004 08:09:06 -0800, "Simon Matthews"
<Si***********@discussions.microsoft.com> wrote:
我遇到了以下正确的架构问题(使用c#
asp.net): -

问题我有一个是如何最好地从一个网页传递收集的数据
用于另一个网页。

我的问题是如何最好地将搜索条件从第一页传递到第二。搜索条件作为结构存在,并在用户按下第一页上的搜索按钮时填充。

1。提出收集用户搜索条件的asp页面
2。在查询SQL后显示带有搜索结果的网格
如果我使用会话来存储它,那么这会导致问题,因为会话
变量在用户的第二次搜索时被覆盖,但是在浏览器的后退按钮上按几下
会让你进入一个页面,期待与之前不再存在的会话中的不同标准。

ViewState似乎不好因为它只适用于回发而且上述问题仍然会导致问题。

我不想在地址行中传递搜索条件,因为这很麻烦允许用户更改和查看它。

我相信你也可以使用Server.Transfer,但我认为这将有一个长期可用的数据相似的问题。 />
任何有关正确方法的指示都是最受欢迎的。
I am having issues with the right way to architecture the following (using c#
asp.net):-

The question I have is how best pass the collected data from one web page
for use in another.

The question I have is how best pass the search criteria from the first page
to the second. The search criteria exists as a structure and is filled when
the user presses the ''Search'' button on the first page.

1. Present an asp page for collecting user search criteria
2. Show grid with results of search after querying SQL

If I use the session to store it, then this causes problems as the session
variable is overwritten on a second search by the user, but a couple of
presses on the back button of the browser will get you to a page expecting
different criteria in the session from earlier which is no longer there.

ViewState seems no good as it only works on postback and the above issue
would still cause a problem.

I do not want to pass the search criteria in the address line as this is
messy and allows the user to change and view it.

I beleive you can also use Server.Transfer but I think this would have a
similiar issue with the data being available long-term.

Any pointers as to the correct approach to this would be most welcome.






您可以使用的替代架构之一考虑是 - 暴露公共[共享]道具在第一页(搜索按钮所在的位置)上进行操作,然后从第二页进行调用。在ASP.NET中,每个与类关联的表单都可以从任何其他类调用。这样我们就不必像使用asp应用程序那样使用查询字符串。


看一下这个链接 - http://authors.aspalliance.com/aspxt...weenpages.aspx

这种方法有问题:当你想回到搜索页面时你从第二页到第一页的标准是什么?实现此目的的一种方法是 - 在第二页上公开公共[共享]属性,并从第一页调用它们。


微软也有关于此的文档,但我发现它找不到方便。希望这有帮助。


Prodip Saha

" Simon Matthews" <硅*********** @ discussions.microsoft.com>在消息新闻中写道:A9 ********************************** @ microsof t.com ...
One of the alternative architechture you can consider is - exposing public [shared] properties on the First page (where the search button located) and call them from the second page. In ASP.NET every form assocaited with a class and it can be called from any other classes. This way we don''t have to use query string like we had to use in asp applications.

Take a look at this link - http://authors.aspalliance.com/aspxt...weenpages.aspx

Problem with this approach: when you want to come back to search page what criteria do you bring back from second page to first page? One way to accomplish this is - exposing public [shared] properties on second page and call them from the first page.

Microsoft also has documentation on this but I could not find it find handy. Hope this help.

Prodip Saha
"Simon Matthews" <Si***********@discussions.microsoft.com> wrote in message news:A9**********************************@microsof t.com...
我遇到了正确构建以下问题的方法(使用c#
asp.net): -

我的问题是如何最好地传递收集的数据从一个网页
用于另一个网页。

我的问题是如何最好地将搜索条件从第一页传递到第二页
。搜索条件作为结构存在,并在用户按下第一页上的搜索按钮时填充。

1.提供用于收集用户搜索条件的asp页面
2.查询SQL后显示搜索结果的网格


如果我使用会话来存储它,那么会导致会话出现问题
变量在用户的第二次搜索时被覆盖,但是在浏览器的后退按钮上按下几个按钮将使您进入一个页面,期望在之前的会话中有不同的标准,不再存在。

ViewState似乎没什么好处,因为它只适用于回发,而上述问题仍然会导致问题。

我不想通过搜索条件在地址行,因为这是凌乱的,并允许用户更改和查看它。

我相信你也可以使用Server.Transfer但我认为这将有一个
与数据相似的问题g长期可用。

任何有关正确方法的指示都是最受欢迎的。
I am having issues with the right way to architecture the following (using c#
asp.net):-

The question I have is how best pass the collected data from one web page
for use in another.

The question I have is how best pass the search criteria from the first page
to the second. The search criteria exists as a structure and is filled when
the user presses the ''Search'' button on the first page.

1. Present an asp page for collecting user search criteria
2. Show grid with results of search after querying SQL



If I use the session to store it, then this causes problems as the session
variable is overwritten on a second search by the user, but a couple of
presses on the back button of the browser will get you to a page expecting
different criteria in the session from earlier which is no longer there.

ViewState seems no good as it only works on postback and the above issue
would still cause a problem.

I do not want to pass the search criteria in the address line as this is
messy and allows the user to change and view it.

I beleive you can also use Server.Transfer but I think this would have a
similiar issue with the data being available long-term.

Any pointers as to the correct approach to this would be most welcome.



感谢您的支持快速回复斯科特。我希望避免使用URL查询

字符串,以免将其暴露给用户。我认为我的问题来自于

C ++ / C#背景我还没有完全失去这种无状态方法!


Scott Allen写道:
Thanks for the quick reply scott. I was hoping to avoid using the URL query
string so as not to expose it to the user. I think my problem is coming from
a C++/C# background I haven''t fully grapsed this stateless approach as yet !

"Scott Allen" wrote:
这样的页面的一个好方法是使用查询字符串。那个数据全部包含在URL中,用户可以收藏喜欢的搜索。 URL确实有大小限制(我认为2048个字符?)

-
Scott
http://www.OdeToCode.com/blogs/scott/

周三,1 2004年12月08:09:06 -0800,Simon Matthews
< Si *********** @ discussion.microsoft.com>写道:
A good technique for pages like this is to use the query string. That
way the data is all contained in the URL and users can bookmark
favorite searches. The URL does have a size limitation though (2048
characters, I think?)

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Wed, 1 Dec 2004 08:09:06 -0800, "Simon Matthews"
<Si***********@discussions.microsoft.com> wrote:
我遇到了以下正确的架构问题(使用c#
asp.net): -

问题我有一个是如何最好地从一个网页传递收集的数据
用于另一个网页。

我的问题是如何最好地将搜索条件从第一页传递到第二。搜索条件作为结构存在,并在用户按下第一页上的搜索按钮时填充。

1。提出收集用户搜索条件的asp页面
2。在查询SQL后显示带有搜索结果的网格
如果我使用会话来存储它,那么这会导致问题,因为会话
变量在用户的第二次搜索时被覆盖,但是在浏览器的后退按钮上按几下
会让你进入一个页面,期待与之前不再存在的会话中的不同标准。

ViewState似乎不好因为它只适用于回发而且上述问题仍然会导致问题。

我不想在地址行中传递搜索条件,因为这很麻烦允许用户更改和查看它。

我相信你也可以使用Server.Transfer,但我认为这将有一个长期可用的数据相似的问题。 />
任何有关正确方法的指示都是最受欢迎的。
I am having issues with the right way to architecture the following (using c#
asp.net):-

The question I have is how best pass the collected data from one web page
for use in another.

The question I have is how best pass the search criteria from the first page
to the second. The search criteria exists as a structure and is filled when
the user presses the ''Search'' button on the first page.

1. Present an asp page for collecting user search criteria
2. Show grid with results of search after querying SQL

If I use the session to store it, then this causes problems as the session
variable is overwritten on a second search by the user, but a couple of
presses on the back button of the browser will get you to a page expecting
different criteria in the session from earlier which is no longer there.

ViewState seems no good as it only works on postback and the above issue
would still cause a problem.

I do not want to pass the search criteria in the address line as this is
messy and allows the user to change and view it.

I beleive you can also use Server.Transfer but I think this would have a
similiar issue with the data being available long-term.

Any pointers as to the correct approach to this would be most welcome.




这篇关于会话变量问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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