Ajax - Exception has been thrown by the target of an invocation
If you're working with Ajax in .NET, you'll probably see an exception like this at some point:
Exception has been thrown by the target of an invocation
Not very helpful. What you need to do is tell the ScriptManager to catch post back errors and re-throw the InnerException. Change your ScriptManager to look like this:
<asp:ScriptManager ID="ScriptManager1" runat="server" OnAsyncPostBackError="ScriptManager1_AsyncPostBackError">
</asp:ScriptManager>
Then add this to your code behind:
protected void ScriptManager1_AsyncPostBackError(object sender, AsyncPostBackErrorEventArgs e)
{
if (e.Exception != null && e.Exception.InnerException != null)
{
ScriptManager1.AsyncPostBackErrorMessage = e.Exception.InnerException.Message;
}}
Now you should see the real exception message come through.
Popular Articles
Last viewed:
- Disable Button on Submit (Prevent multiple submits)
- C# Download File with Progress Bar
- Find a control in a TemplateField programmatically
- Building a Web Service in ASP.NET 3.5
- Using Stored Procedures in the Entity Framework with Scalar Return Values
- Get the list of ODBC data source names programatically using C#
Similar
- Fixing Relative Paths in C# ASP.NET When Using Url Rewriting
- How to Highlight the Day in the ASP.NET Calendar Control with the SelectedDate Property
- Global.asax Events in IIS 6 and IIS 7 for Static Resources
- Create a Windows-style GroupBox in ASP.NET
- Changing the Application Pool Identity with Windows Server 2008 and IIS 7


Recent comments
3 days 6 hours ago
3 days 9 hours ago
3 days 21 hours ago
6 days 19 hours ago
1 week 2 days ago
1 week 2 days ago
1 week 2 days ago
1 week 2 days ago
1 week 4 days ago
2 weeks 2 days ago