在asp.net server.transfer? [英] server.transfer in asp.net?

查看:59
本文介绍了在asp.net server.transfer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我编写 server.transfer("defaul2.aspx"); 网址 default2.aspx 中的内容未显示,而是显示了 defaul.aspx 页面.当我写 response.redirect("default2.aspx");

When i write server.transfer("defaul2.aspx"); in url default2.aspx is not displaying instead of it is showing defaul.aspx page. when i write response.redirect("default2.aspx");

显示有什么不同.

推荐答案

这是因为Server.Transfer() Response.Redirect()不能以相同的方式工作.

That's because Server.Transfer() and Response.Redirect() don't work the same way.

Server.Transfer()不会结束当前请求,它仅指示ASP.NET停止呈现当前页面并开始呈现新页面.从客户端的角度来看,客户端是最明智的选择,从服务器的角度来看,服务器仍在响应初始请求,因此地址栏中显示的URL不会更改.

Server.Transfer() doesn't end the current request, it only instructs ASP.NET to stop rendering the current page and start rendering the new page instead. The client is none the wiser, from its point of view the server is still responding to the initial request, so the URL displayed in the address bar does not change.

Response.Redirect()结束当前请求并发送 302 对客户端的响应代码.然后,客户端向重定向的URL发出另一个 HTTP请求并处理响应.由于客户端知道URL已更改,因此它将在其地址栏中显示重定向的URL.

Response.Redirect() ends the current request and sends a 302 response code to the client. The client then issues another HTTP request to the redirected URL and processes the response. Since the client knows that the URL has changed, it displays the redirected URL in its address bar.

这篇关于在asp.net server.transfer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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