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 4590228
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:13:10+00:00 2026-05-21T22:13:10+00:00

In MVC 3, is it possible to determine if an action is a result

  • 0

In MVC 3, is it possible to determine if an action is a result of a POST or GET method? I know you can decorate the actions with [HttpPost] and [HttpGet] to fire a specific action if one of those happens. What I’d like to do is leave those attributes off and programmatically determine which one caused the action.

The reason is, because of the way my search page is architected, I’m storing the search model in TempData. The initial search causes a POST to the search results page, but the paging links are all just links to “/results/2” (for page 2). They examine TempData to see if the model is in there an use it if so.

This causes problems when someone uses the back button to go to the search form and resubmit it. It’s still picking up the model in TempData instead of using the new search criteria. So if it’s a POST (i.e. someone just submitted the search form), I want to clear out TempData first.

  • 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-21T22:13:11+00:00Added an answer on May 21, 2026 at 10:13 pm

    The HttpMethod property on the HttpRequest object will get it for you. You can just use:

    if (HttpContext.Current.Request.HttpMethod == "POST")
    {
        // The action is a POST.
    }
    

    Or you can get the Request object straight off of the current controller. It’s just a property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I get the controller action (method) and controller type that will be
In ASP.NET MVC, is it possible to define routes that can determine which controller
Possible Duplicate: Mvc Html.ActionButton With ASP.NET MVC 3 I know how to create a
Is it possible to determine if ASP.NET MVC 3 has successfully found any values
Using spring 3.0 MVC: Is it possible to programatically execute a controller's action, and
I have an MVC 3 Application which has JSON POST'ed to an Action. Everything
I am wondering if the following is possible in MVC 3 I basically have
Possible Duplicate: ASP.NET MVC: No parameterless constructor defined for this object I'm working on
Is it possible to create ASP.NET MVC applications in VS 2010? What should I
Is it possible to setup ASP.NET MVC 2 to work with a MySQL database?

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.