How to catch an error in an MVC 5 method using Application Insights
i have installed application insights mvc 5 asp.net 4.5 app. sending kinds of data portal. now, want see if can use catch specific error that's happening in method.
{
using (var uow = _unitofworkfactory.create())
{
uow.merchantrepository.update(merchant);
await uow.savechangesasync();
return merchant;
}
}
i'm trying catch error in method.
{
var consumer = await _merchantconsumerservice.findasync(id);
}
how go using application insights catch , report errors? use try , catch on app, i've read documentation on ai , don't understand how implement in code.
any appreciated. thanks!
hi,
i'll try explain above example - after installing application insights nuget, can create telemetryclient, used send telemetry events application insights backend.
to so, create telemetryclient in catch block:
var telemetryclient = new telemetryclient();
and report exception:
telemetryclient.trackexception(ex);
when exception send application insights backend, able see in azure portal in application insights resource, including full stack trace should investigate root cause.
you can set applications instrumentation key (to indicate specific application insights resource) running following in startup.cs:
telemetryconfiguration.active.instrumentationkey = “ikey”;
please let me know if better understand whats going on.
thanks,
asaf
Visual Studio Development , Visual Studio Team Foundation Server > Application Insights (AI)
Comments
Post a Comment