I want to implement toastr.js in dotvvm. I created an exception filter which catch all the exception errors on the viewmodel:
public class ErrorLoggingActionFilter : ExceptionFilterAttribute
{
protected override async Task OnPageExceptionAsync(IDotvvmRequestContext context, Exception exception)
{
//context.CustomResponseProperties.Add("Error", exception.Message);
// Inject JavaScript code to display toastr notification
// Get the exception message
string errorMessage = exception.Message;
// Inject JavaScript code to display toastr notification
string toastrScript = $"<script>toastr.error('{errorMessage}');</script>";
context.ResourceManager.AddInlineScript(toastrScript);
// Mark the exception as handled
context.IsPageExceptionHandled = true;
await base.OnPageExceptionAsync(context, exception);
}
}
but i'm having hard time adding the toastr.js and implementing it.