请求和在ASP.Net响应使用 [英] Use of Request and Response in ASP.Net
问题描述
之间的区别是什么?请求和响应术语在ASP.net?
我使用ASP.net 3.5。
What is the difference between "Request" and "Response" terminologies in ASP.net? I am using ASP.net 3.5.
假设我必须让别人了解这些条款。我应该说什么?
Suppose I have to make somebody understand about these terms. What should i say ?
推荐答案
该请求是一个Web客户端发送到Web服务器。响应是Web服务器发送 - 好吧,为了响应。两者都在HTTP规范中定义。 (它们的结构如何,它们包括哪些信息和元数据等)
The Request is what a web client sends to the web server. The Response is what the web server sends - well, in response. Both are defined in the HTTP specification. (How they are structured, what information and meta data they include, etc.)
ASP.Net封装在各自的类这些概念使它们编程访问。
ASP.Net encapsulates these concepts in respective classes to make them programmatically accessible.
的Request.QueryString
如果您有类似下面的网址:
If you have a URL like the following:
http://www.host.com/Page.aspx?name=Henry&lastName=Ford
在之后的部分?
是查询字符串的。 ( NAME =亨利放; lastName的福特=< =查询字符串
)
这是参数传递给服务器作为的请求的第一部分常用的方式。在你的服务器code可以使用的Request.QueryString
访问这些参数:
This is one common way to pass arguments to the server as part of the Request. In your server code you can access these arguments by using Request.QueryString
:
string name = Request.QueryString["name"];
string lastName = Request.QueryString["lastName"];
的Response.Redirect
您服务器收到的请求的一个页面,你想的重定向的到另一个位置。随着的Response.Redirect()
方法,你一个具体的一条信息添加到的响应的导致该浏览器马上去这个其他网页
Your server received a Request for a page and you want to redirect to another location. With the Response.Redirect()
method, you add a specific piece of information to the Response that causes the browser to immediately go to this other page.
// This tells the browser to load google
Response.Redirect("http://www.google.com");
这篇关于请求和在ASP.Net响应使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!