Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 815291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:39:40+00:00 2026-05-15T01:39:40+00:00

I have an ASP.Net questionnaire application that resubmits data to the same page, showing

  • 0

I have an ASP.Net questionnaire application that resubmits data to the same page, showing a different question each time. There are BACK and NEXT buttons to navigate between questions.

I would like to detect when the form is submitted due to a browser refresh vs. one of the buttons being pressed. I came across a WebForms approach but don’t know how to apply those principals in an MVC 2 application since page events aren’t available (as far as I know… I’m pretty new to Microsoft’s MVC model).

How would one apply that principle to MVC 2? Is there a better way to detect refresh?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:39:41+00:00Added an answer on May 15, 2026 at 1:39 am

    You could use the redirect-after-post pattern with TempData. Example:

    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.

    And to illustrate this:

    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");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ASP.NET page with an asp:button that is not visible. I can't
I have a ASP.NET application that we've written our own logging module for. My
Curious what recommendations anyone has. I have an existing asp.net forms application that does
I am writing a questionnaire application with ASP.NET MVC 2. I have a set
I have asp.net form that contains fields. When I access this window, my javascript
I have an Asp.NET application (VS2008, Framework 2.0). When I try to set a
I have a ASP.NET 1.1 application, and I'm trying to find out why when
I have a asp.net page, and would like to know whether script1 is already
im trying to create a database for a feedback application in ASP.net i have
I have ASP.NET web pages for which I want to build automated tests (using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.