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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:36:14+00:00 2026-05-12T09:36:14+00:00

The situation I have is I am handling OnException in my controller. Depending on

  • 0

The situation I have is I am handling OnException in my controller. Depending on the type of exception I would like to return a javascript result. The action method that threw the exception was called by submitting an ajax form. The ajax form handles the success event. In my OnException method I am setting ExceptionHandled = true per all the examples I’ve seen. The problem is even though an exception was thrown and I returned a JavascriptResult the success method is called and the javascript I returned isn’t executed. Any suggestions as to why this is happening and how I can get the JavascriptResult to execute.

  • 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-12T09:36:14+00:00Added an answer on May 12, 2026 at 9:36 am

    Here’s the sequence of events:

    1. the browser sent an ajax request
    2. the action method on the server started executing, and threw an exception.
    3. your OnException method got a chance to look at the exception, and decided to set ExceptionHandled=true.
    4. further, your OnException method returned a JavascriptResult
    5. as ExceptionHandled was set to true, MVC stops the exception processing chain at that point, and returns the JavascriptResult to the browser, with an HTTP result code of 200 OK
    6. The ajax code on the browser receives the result, and interprets it as indicating all is well; it then calls OnComplete, followed by OnSuccess.

    Your options are:

    1. Set a status code of 500 on the response before returning from OnException. The browser will call OnComplete, then OnFailure.

    2. Deal with the returned value in OnComplete, instead of in OnSuccess, and then return false to indicate OnSuccess should not be called.

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

Sidebar

Related Questions

What's the best method for handling a situation where you have an ASP.Net Dropdownlist
i have situation like this: class IData { virtual void get() = 0; virtual
I am curious how people are handling the following situation. Let's say we have
I want to ask about what your approach looks like handling a situation like
I have situation when I need to communicate with Java process somehow. Java handling
I have an annoying situation where the late bound invocation of a method throws
By 'situation specific' I mean it uses some data that it would have access
I am in a situation where I would like to accept a LOT of
Pseudo-situation: have a class (let's say BackgroundMagic ), and it has Start() and Stop()
Situation: I have a simple XML document that contains image information. I need to

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.