English 中文(简体)
侦查Browser Refresh vs. Form Submit in ASP. Net MVC 2 P-4, 2 P-3, 2 FS, 2 NS
原标题:Detect Browser Refresh vs. Form Submit in ASP.Net MVC 2

我有一个伙伴关系。 将数据重新提交同一页的调查问卷净应用,每次都显示不同的问题。 有一些BACK和NEXTuttons在问题之间联系。

我愿发现,在提交表格时,由于有人要求复读书。 我走过了rel=“nofollow noreferer”>WebForms approach,但不知道如何在MVC 2号申请中应用这些本金,因为页面活动有线(我知道......)。 I m pretty new to Morgan s MVC model.

如何将这一原则适用于第2号行政指示? 是否有更好的办法检测复习?

最佳回答

您可使用以下中继职位模式:http://msdn.microsoft.com/en-us/library/system.web.mvc. Controllerbase.tempdata.aspx” rel=“诺referer”>TempData/code>。 例:

  1. The Back and Next buttons POST a form to a controller action
  2. The controller action puts some state into the TempData and redirects to another controller action which will verify that the data is in TempData and return the view
  3. The user presses F5 on the browser, the previous action is called on GET and as the state is no longer into TempData you know the user pressed F5 and didn t pass through the form submission.

说明这一点:

public class HomeController: Controller
{
    public ActionResult Index()
    {
        var state = TempData["state"];
        if (state == null) 
        {
            // the user directly arrived on this action without passing 
            // through the form submission
        }
        return View();
    }

    [HttpPost]
    public ActionResult Index(string back)
    {
        TempData["state"] = new object();
        return RedirectToAction("Index");
    }
}
问题回答

暂无回答




相关问题
How To update contextMenu after it shows in flex

The thing is I load context menu items dynamically and it takes time to load, so context menu appears with default values the first time. But if you right-click again, yo see the loaded values. Is ...

WPF listbox dynamically populated - how to get it to refresh?

I am new to WPF, so I thought this was simple. I have a form with a listbox and a button. In the click handler for the button I do something iteratively that generates strings, which I want to put in ...

PHP header("Refresh") problems

I have some code like: header( Refresh: 15; url= . $url); This works fine, except when people are visiting this url via Twitter (posted from a Hootesuite client). Apparently, in all browsers other ...

Refresh Database On Pic

我正试图将我的q子的最新版本推到我的装置上,迄今为止,除了每次重新命名外,没有找到其他办法。 斜线(待定) 页: 1

jQuery, remove item from middle of list, then refresh list?

I have a ul list that is loaded by an included PHP file. Those items have a "Delete" link that removes them from the list and the database. When an item is removed from the center of the list using ...

HTML - input value kept after Refresh

Usually, when a refresh is made on an HTML page, the values for input fields are kept (unless you do Ctrl+F5). Is there a header or other type of setting than can change this behavior, without ...

WPF Datagrid refresh data

I use the following code to bind an arraylist to a datagrid //fill datagrid public DataTable configData { get { DataSet dsTemp = new DataSet(); ...

Python won t refresh URL to receive new forex ticker data

I am trying to save updated Forex ticker data from this website: http://forex.offers4u.biz/TickDBReadDB.php?p=EURUSD just hit refresh to update the ticker. when I use my little python script, it ...