Toastr Notifications in Microsoft.AspNetCore.Mvc

Null Pointer picture Null Pointer · Jun 17, 2017 · Viewed 10.3k times · Source

I'm using Toastr notification plugin in my dotnetCore razor application to display status messages. These notifications are working perfectly fine with all ajax calls and their responses (in javascript).

But I need to configure these responses on simple razor actions;

asp-action="ViewJobs" asp-controller="Job"

Like if there's some loading issue or rights issue, I need to show error messages as toastr notifications. I did some RnD on it and found out different solutions but nothing worked out for me.

I've tried MVC wrapper for Toastr that handles all kind of toastrs in controller but its specific for MVC and trying to add some files in App_Code that is not available in dotnetcore and furthermore its having @helper tag that is no more supported in dotnetcore. (Tell me if there's any other workaround to use this solution?)

Then I tried this solution NToastNotify , but got stuck again, because it needs Microsoft.AspNetCore.Mvc (>= 1.1.2) while I'm using version 1.0.0 and I cannot update my version because then I need to update so many files in my project.

So Is there any other solution to handle this situation?? Can't I fulfill my requirement with simple viewbag or tempdata ??

Any kind of help will be appreciated.

Answer

Null Pointer picture Null Pointer · Jun 18, 2017

For anyone who is stuck like me and in search of solution, I ended up using NToastNotify library after updating my packages to its required versions and it is working perfectly fine.