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

  • Home
  • SEARCH
  • 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 6909511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:41:57+00:00 2026-05-27T08:41:57+00:00

Why is Json Request Behavior needed? If I want to restrict the HttpGet requests

  • 0

Why is Json Request Behavior needed?

If I want to restrict the HttpGet requests to my action I can decorate the action with the [HttpPost] attribute

Example:

[HttpPost]
public JsonResult Foo()
{
    return Json("Secrets");
}

// Instead of:
public JsonResult Foo()
{
    return Json("Secrets", JsonRequestBehavior.AllowGet);
}

Why isn’t [HttpPost]sufficient?
Why the framework “bugs” us with the JsonRequestBehavior.AllowGet for every JsonResult that we have. If I want to deny get requests I’ll add the HttpPost attribute.

  • 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-27T08:41:57+00:00Added an answer on May 27, 2026 at 8:41 am

    MVC defaults to DenyGet to protect you against a very specific attack involving JSON requests to improve the liklihood that the implications of allowing HTTP GET exposure are considered in advance of allowing them to occur.

    This is opposed to afterwards when it might be too late.

    Note: If your action method does not return sensitive data, then it should be safe to allow the get.

    Further reading from my Wrox ASP.NET MVC3 book

    By default, the ASP.NET MVC framework does not allow you to respond to
    an HTTP GET request with a JSON payload. If you need to send JSON in
    response to a GET, you’ll need to explicitly allow the behavior by
    using JsonRequestBehavior.AllowGet as the second parameter to the Json
    method. However, there is a chance a malicious user can gain access to
    the JSON payload through a process known as JSON Hijacking. You do not
    want to return sensitive information using JSON in a GET request. For
    more details, see Phil’s post at
    http://haacked.com/archive/2009/06/24/json-hijacking.aspx/ or this SO post.

    Haack, Phil (2011). Professional ASP.NET MVC 3 (Wrox Programmer to
    Programmer) (Kindle Locations 6014-6020). Wrox. Kindle Edition.

    Related StackOverflow question

    With most recents browsers (starting with Firefox 21, Chrome 27, or IE 10), this is no more a vulnerability.

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

Sidebar

Related Questions

I've got a jquery json request and in that json data I want to
How can I assert my Ajax request and test the JSON output from Ruby
I have a json string in an action of MVC controller. I want to
I have a REST service which takes a JSON request. I want to validate
I have a controller action like: Public ActionResult MyAction(int[] stuff){} I make a JSON
I have an jQuery JSON request, that loads some JSON from another server (ex.
I'm using JQuery to make a JSON request back to the server and it
I am trying to create an ActiveRecord object via a JSON request. However the
I don't have any idea how to post a JSON RPC request using Obj-C.
I have a request that returns a JSON object with a single property which

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.