javascript - 用户提交表单后在 Web 应用程序上发送推送通知

标签 javascript asp.net webforms

我们有一个在 ASP.Net Web 表单上运行的 Web 应用程序。用户转到请求一些信息的登陆页面,这些信息会存储在 SQL 数据表中,并触发并向联络中心发送电子邮件通知。

我们需要,当某些用户提交表单时,联络中心代理会收到来自浏览器的推送通知。

登录页面位于特定 URL,例如 www.mysite.com/landing.aspx,而联系中心的前台位于 www.mysite.com/admin

到目前为止,我们已经尝试使用 JavaScript。我们有一个代码每分钟在数据库中搜索新记录,但它给服务器加载了太多的工作!

这是执行一分钟任务后加载的 JavaScript:

    window.onload = function notifyMe() {
        // Let's check if the browser supports notifications
        if (!("Notification" in window)) {
            alert("This browser does not support desktop notification");
        }

        // Let's check whether notification permissions have already been granted
        else if (Notification.permission === "granted") {
            // If it's okay let's create a notification
            var notification = new Notification("New form request received!");
        }

        // Otherwise, we need to ask the user for permission
        else if (Notification.permission !== 'denied') {
            Notification.requestPermission(function (permission) {
                // If the user accepts, let's create a notification
                if (permission === "granted") {
                    var notification = new Notification("New form request received!");
                }
            });
        }

        // At last, if the user has denied notifications, and you 
        // want to be respectful there is no need to bother them any more.
    }
</script>

您知道实现此目标的更好方法吗?谢谢!

最佳答案

关于javascript - 用户提交表单后在 Web 应用程序上发送推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56227810/

相关文章:

javascript - 如何将 Node js 包添加到 Meteor 应用程序中?

javascript - 带有参数的子项在 react 路由器中重新加载页面

c# - 如何将 Tally 与 Asp.Net Web 应用程序集成?

c# - 表单例份验证 - 共享 Cookie MVC 和 Web 表单

javascript - 根据多个模型属性过滤主干集合

javascript - 我的水平菜单被我自己的图像隐藏了

c# - ASP.NET WEB API 外部登录

c# - 如何使用数据库表在 C# 中创建自动建议文本框

asp.net - 如何使div可点击

c# - 添加 <asp :image> from codebehind