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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:15:49+00:00 2026-05-20T07:15:49+00:00

I am using a rescue derived from MvcContrib: public class RescueAttribute : MvcContrib.Filters.RescueAttribute {

  • 0

I am using a rescue derived from MvcContrib:

public class RescueAttribute : MvcContrib.Filters.RescueAttribute
{
    public RescueAttribute(string view) : base(view)
    {
        IgnoreAjax = false;
    }

    public RescueAttribute(string view, params Type[] exceptionTypes) : base(view, exceptionTypes)
    {
        IgnoreAjax = false;
    }

    protected override ActionResult CreateActionResult(Exception exception, ExceptionContext context)
    {
        var controller = (string) context.RouteData.Values["controller"];
        var action = (string) context.RouteData.Values["action"];
        var model = new HandleErrorInfo(exception, controller, action);

        if (context.Controller.ControllerContext.HttpContext.Request.IsAjaxRequest())
        {
            return new JsonResult(model);
        }
        return base.CreateActionResult(exception, context);
    }
}

Now when using the file upload in jQuery.form, Request.IsAjaxRequest() returns false. Apparently this is because you can’t actually upload a file using json; this plugin generates a hidden iframe to do the upload.

To compensate I am appending a hidden input to any form that is submitted with jquery.form and has file inputs:

$(this).append('<input type="hidden" name="X-Requested-With" value="XMLHttpRequest" />');

It’s good enough to fool IsAjaxRequest. Is there any reason why I shouldn’t do this?

  • 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-20T07:15:50+00:00Added an answer on May 20, 2026 at 7:15 am

    This method is fine.

    JQuery and other client libraries put X-Requested-With in the headers. However, the ASP Ajax helpers use hidden form elements just as you did above.

    The important thing is that IsAjaxRequest() checks both form fields and headers. So if it finds XMLHttpRequest for X-Requested-With in either place, it returns true.

    Nice technique. I might use it one day.

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

Sidebar

Related Questions

I am using Log Me In Rescue API to pull some reports from their
Using import datetime in python, is it possible to take a formatted time/date string
I'm using some ruby code wrapped in a begin - rescue block but somehow
Using Rails 3.1.0 def create @practice = Practice.new(params[:practice]) respond_to do |format| if (current_user.practices <<
I'm presented with a problem of using query string variables in a RESTful Asp.net
I've upgraded my app from using config.gem to a Gemfile with bundler and have
I want to get data from an API using Python. The API documentation give
I'm using the devise gem (1.4.2) and rails (3.0.7). I've got a view with
I'm writing a little client using Ruby and Savon. The interface changed significantly from
I am using cardmagic/contacts gem to import contacts from email addresses in my application.

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.