重定向页面 [英] Redirecting a page

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

问题描述



我需要从第一页移到第二页.

情况1:如果我在第一页的javascript中执行document.form.submit().控制权转到第二页,并保留第一页的所有隐藏字段,并且URL更改.

情况2:我在服务器事件发生时进行了server.transfer的按钮处理,它也转到第二页,其中保留了所有隐藏的字段,但保持URL与第一个相同.

情况3:我做了Response.Redirect,这次更改了网址,并且在第二页上没有隐藏字段!!

请提供输入信息,以说明为什么我在这些方法中获得三个不同的结果.而且我不能在request.redirect中保留隐藏的字段吗?

提前谢谢.


欢呼〜
Divya

Hi,

I need to move on second page from first page.

Case 1: If I do document.form.submit() in javascript on first page. Control goes to 2nd page and persists all the hidden fields of first page and URL gets changnes.

Case 2: I did server.transfer at server eventof a button it also goes to 2nd page persisting all the hidden fields but keeping the URL same as teh first.

Case 3: I did Response.Redirect, this time url changned and on 2nd page NO hidden field was persisted !!

Please provide me inputs as why I am getting three different outcomes in these approaches. And can I not persist the hidden fields in response.redirect ?

Thanks in advance.


Cheers ~
Divya

推荐答案

让我回答您问题的下一部分.我将在评论部分将您的问题粘贴到此处.
Let me answer the next part of your question. I will paste your question here from the comments section.
Thanks for quick reply. I am clear about the server.transfer and response.redirect. But as case 1 in my question it persists the hidden fields (showing charactor of .transfer) and changes URL (showing redirect effect). I dont understand why so .. Please help.


这是您的情况-
情况1:如果我在第一页的javascript中执行document.form.submit().控制权转到第二页,并保留第一页的所有隐藏字段,并且URL得到更改.

您需要了解很多内容.

当您说form.submit()时,您正在将表单提交到服务器.数据将被发布回网页,该网页由您提交的表单的"action"属性确定.因此,隐藏的字段也可用于发布的页面.
您可以发回到同一页,这是ASP.NET页的默认行为.
使用Response.Redirect重定向页面时,它会将您重定向到其他服务器(可以相同).因此,默认情况下,该值对重定向页面不可用. (Http是无状态协议,您知道的.)

您需要阅读有关Server.TransferResponse.Redirect方法的更多信息.另外,您还需要了解ASP.NET页面的页面生命周期.链接: MSDN:ASP.NET页面生命周期概述 [ MSDN:将用户重定向到另一个页面 [ ^ ]

阅读它,我相信您所有的疑问都会清楚. :thumbsup:

我的回答可能不太清楚.如果您有任何疑问,请告诉我.


Here is your case one -
Case 1: If I do document.form.submit() in javascript on first page. Control goes to 2nd page and persists all the hidden fields of first page and URL gets changes.

There is a lot you need to understand.

When you say form.submit() you are submitting the form to the server. The data gets posted back to the web page which is determined by the ''action'' attribute of the form that you are submitting. So the hidden field is also available to the posted page.
You may post back to the same page, which is the default behavior for a ASP.NET page.
When you redirect the page using Response.Redirect, it redirects you to a different server (can be same). So by default the values should not available to the redirected page. (Http is a stateless protocol, you know that).

You need to read more about Server.Transfer and Response.Redirect methods. Also you need to understand the page life cycle of ASP.NET page. Link: MSDN: ASP.NET Page Life Cycle Overview[^]

And yes, there is a very good article on MSDN about navigation options in ASP.NET. Here it is: MSDN: Redirecting Users to Another Page[^]

Read it, I am sure all your doubts will be clear. :thumbsup:

I may not be very clear in my answer. Let me know if you have any doubts.


检查此内容,
http://www.csharpfriends.com/articles/getarticle.aspx?articleid=15 [ ^ ]

http://www.dotnetspider.com/forum/21599-Difference-服务器间传输响应-Re.aspx [ ^ ]

http://www.dotnetspider.com/forum/ViewForum.aspx?ForumId=29793 [ ^ ]
Check this,
http://www.csharpfriends.com/articles/getarticle.aspx?articleid=15[^]

http://www.dotnetspider.com/forum/21599-Difference-between-Server-Transfer-Response-Re.aspx[^]

http://www.dotnetspider.com/forum/ViewForum.aspx?ForumId=29793[^]


这篇关于重定向页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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