且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

邮政重定向获取asp.net

更新时间:2022-12-09 12:38:36

在你回发到窗体你只需要回传后执行重定向。

After you postback to the form you simply need to perform a redirect after the postback.

DoPostbackProcessing();
Response.Redirect("FormConfirmationPage.aspx");

作为一个非常简单的例子,基本上只要你重定向(GET)到另一个页面,则用户不能复制回发。当然,如果有在论坛的任何错误你可能不希望再直接,但这种下降到个性化需求。

As a very simple example, basically as long as you redirect (GET) to another page then the user cannot duplicate the postback. Of course if there are any errors in the forum you may not want to re-direct, but this is down to individual requirements.

编辑:这方面的一个很好的例子就是搜索,而不是回发,然后进行搜索,你会重定向和GET:

A good example of this is search, instead of posting back and then performing the search you would redirect and GET:

// Instead of performing search now we will redirect to ourselves with the criteria.
var url = "SearchPage.aspx?criteria=" + txtSearch.Text;
Response.Redirect(url);

这会重新定向,页面检查条件查询字符串,然后执行搜索,当用户刷新一遍搜索 - 再加上他们可以书签的页面进行即时搜索

This then redirects, the page then checks for a criteria query string and THEN performs the search, and when the user refreshes it searches again - plus they can bookmark the page for instant searching.