0

I want to return sweet alerts from controller to warn a user about customized errors according to my needs. I could not figure it out in controller. Basically I throw userfriendlyexception from my action but errors are shown in another way. I have referenced abp.UI in the controllers. I have changed the layout's html and css, but still including sweet alert's js and css files and it's working in the service level as a proof.

Thanks in advance.

4

1 回答 1

2

ASP.NET Boilerplate 根据控制器 Action 的返回类型有不同的行为:

  • 如果操作返回JsonResult或另一个对象(或它们的异步Task<T>版本),则它返回一个AjaxResponse并且客户端可以处理它并显示一条甜蜜的消息。因此,如果您使用 AJAX 调用操作而不返回 HTML,则显式使用JsonResult其他 POCO 对象作为您的操作的返回值。

  • 如果操作的返回类型是ActionResult, ViewResultor PartialViewResult(或它们的异步Task<T>版本),则它返回错误视图。

有关更多信息,请参阅文档:https ://aspnetboilerplate.com/Pages/Documents/AspNet-Core#exception-filter

于 2017-06-22T02:11:39.153 回答