简体   繁体   English

什么是ASP.NET中的跨页面发布?

[英]What is cross-page posting in ASP.NET?

I have a few questions about cross-page posting in ASP.NET: 我有几个关于ASP.NET中跨页面发布的问题:

  • What is cross-page posting in ASP.NET? 什么是ASP.NET中的跨页面发布?
  • When should I consider using it in my web application? 我何时应该考虑在我的网络应用程序中使用它?
  • What are pros and cons of cross-page posting? 跨页面发布的优缺点是什么?

Basically, cross-page posting means that you are posting form data to another page as opposed to posting form data back to the same page (as is the default in ASP.NET). 基本上,跨页面发布意味着您将表单数据发布到另一个页面,而不是将表单数据发布回同一页面(这是ASP.NET中的默认设置)。 This can be useful when you want to post data to another page and don't want to incur the overhead of reloading the current page simply to redirect the user to another page via an HTTP 302 (ie Response.Redirect ). 当您想要将数据发布到另一个页面并且不希望产生重新加载当前页面的开销只是为了通过HTTP 302将用户重定向到另一个页面(即Response.Redirect )时,这可能很有用。

For a more information please see Cross-Page Posting in ASP.NET Web Pages : 有关更多信息,请参阅ASP.NET网页中的跨页面发布

By default, buttons and other controls that cause a postback on an ASP.NET Web page submit the page back to itself. 默认情况下,在ASP.NET网页上导致回发的按钮和其他控件将页面提交回自身。 This is part of the round-trip cycle that ASP.NET Web pages go through as part of their normal processing. 这是ASP.NET Web页面作为正常处理过程的一部分往返循环的一部分。 For details, see Introduction to ASP.NET Web Pages. 有关详细信息,请参阅ASP.NET网页简介。

Under some circumstances, you might want to post one page to another page. 在某些情况下,您可能希望将一个页面发布到另一个页面。 For example, you might be creating a multi-page form that collects different information on each page. 例如,您可能正在创建一个多页表单,用于在每个页面上收集不同的信息。 In that case, you can configure certain controls (those that implement the IButtonControl interface, such as the Button control) on the page to post to a different target page. 在这种情况下,您可以在页面上配置某些控件(实现IButtonControl接口的控件,例如Button控件)以发布到不同的目标页面。 This is referred to as cross-page posting. 这称为跨页面发布。 Cross-page posting provides some advantages over using the Transfer method to redirect to another page. 与使用Transfer方法重定向到另一个页面相比,跨页面发布提供了一些优势。 For details, see Redirecting Users to Another Page. 有关详细信息,请参阅将用户重定向到另一页。

Cross - page posting is targeting a different page from the original page. 跨页面发布的目标是与原始页面不同的页面。 ASP.NET is based on the post-back model where the same page that sent it to you processes the response. ASP.NET基于回发后模型,其中发送给您的同一页面处理响应。

COnsider using it when you have lots of entry points that need the same processing. 当您有许多需要相同处理的入口点时,它会使用它。

Pros: single point of handling common routine Cons: pages are hard-linked and have intimate knowledge. 优点:处理常见常规的单点缺点:页面是硬链接的,并且具有亲密的知识。 AKA coupling. AKA耦合。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM