Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从与收件人不同的来源发送邮件?_Javascript_Asp.net Core 2.2_Postmessage_Angular10 - Fatal编程技术网

Javascript 如何从与收件人不同的来源发送邮件?

Javascript 如何从与收件人不同的来源发送邮件?,javascript,asp.net-core-2.2,postmessage,angular10,Javascript,Asp.net Core 2.2,Postmessage,Angular10,我有一个问题,我不知道如何绕过。我正在开发Angular客户端应用程序和ASP.NET Core 2.2 Web API,在我的Web API控制器中,我需要调用一个视图并向其传递一个模型,这很好: (...) else { TokenResponseViewModel response = GenerateResponse(user); return View(response);

我有一个问题,我不知道如何绕过。我正在开发Angular客户端应用程序和ASP.NET Core 2.2 Web API,在我的Web API控制器中,我需要调用一个视图并向其传递一个模型,这很好:

(...)
else
            {
                TokenResponseViewModel response = GenerateResponse(user);

                return View(response);
            }
视图正在分析模型并发送一条消息,其中包含:

但问题是我得到了:

未能在“DOMSWINDOW”上执行“postMessage”:错误为 („http://localhost:4200)提供目标源代码 („http://localhost:50962))

原因是Web API控制器端点返回带有端口
50962
的视图,而Angular客户端应用程序使用端口
4200
运行。我已经没有办法解决这个问题了

我得到了同样的结果

<body>
    <script>
        var accessToken = "@Model.Token";
        var message = {};
        if (accessToken) {
            message.status = true;
            message.token = '@Model.Token';
            message.email = '@Model.Email';
            message.refreshToken = '@Model.RefreshToken';
            message.user = '@Model.User';
        } else {
            message.status = false;
        }
        console.log('posting message');
        this.window.postMessage(JSON.stringify(message), "http://localhost:4200");
        console.log('posted message');
    </script>
</body>
this.externalProviderWindow = window.open(url, "ExternalProvider", params, false);
    this.externalProviderWindow.addEventListener("message", this.handleMessage.bind(this), false);
  }

  private handleMessage(event: Event) {
(...)//process "message"
}