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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:19:05+00:00 2026-05-31T12:19:05+00:00

Since ASP.NET MVC2, when you try to return a Json result without additional information,

  • 0

Since ASP.NET MVC2, when you try to return a Json result without additional information, you get an error:

This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request.

You must now set the property JsonRequestBehavior to the value AllowGet:

result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;

I read on a post that this prevents hijacking.

I wanted to know if there is an equivalent with Json.Net to prevent this type of attack.

Here is my code to create the Json result:

  protected JsonNetResult JsonNet(object data)
  {
     JsonNetResult result = new JsonNetResult();

     result.Data = data;

     return result;
  }

And if you want to know where I found the JsonNetResult, here is a link.

Thank you very much.

  • 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-31T12:19:07+00:00Added an answer on May 31, 2026 at 12:19 pm

    You don’t need it because in the custom JsonNetResult that you have shown there’s no such test. So you will never get an exception like the one you would get with the standard JsonResult if you invoke the action with GET.

    If you wanted you could implement exactly the same property on your custom JsonNetResult property.

    public class JsonNetResult : ActionResult
    {
        public JsonNetResult()
        {
            SerializerSettings = new JsonSerializerSettings();
            JsonRequestBehavior = JsonRequestBehavior.DenyGet;
        }
    
        public JsonRequestBehavior JsonRequestBehavior { get; set; }
        ....
    
        public override void ExecuteResult(ControllerContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");
    
            var httpMethod = context.HttpContext.Request.HttpMethod;
    
            if (JsonRequestBehavior == JsonRequestBehavior.DenyGet && 
                string.Equals(httpMethod, "GET", StringComparison.OrdinalIgnoreCase))
            {
                throw new InvalidOperationException("You can't access this action with GET");
            }
    
            ...
        }
    }
    

    and if you wanted to explicitly allow this for a particular action:

    protected ActionResult JsonNet(object data)
    {
        JsonNetResult result = new JsonNetResult();
        result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
        result.Data = data;
        return result;
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have wanted to try GAE since launch, but coming from ASP .NET and
Since asp.net mvc did away with many controls that were in webforms, does this
A number of questions have been asked on this topic before, but since ASP.NET
Since ASP.NET response filtering and post-cache substitution are not compatible, I need an alternative
I've been working in ASP.NET for several years now (since the 1.0 days!), but
It's been a while since I've created a new ASP.NET web application. (I've been
i'm just starting to use asp.net mvc.. since i'm not familiar with it, i
I am using FckEditor in Create.aspx page in asp.net mvc application. Since I need
I am trying to generate an html div in asp.net. Since a div is
I have implemented Unity within my Asp.Net MVC2 project. I am currently registering my

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.