Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/378.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
我们可以在.NetCore WebApi中沿c#放置JavaScript代码吗_Javascript_C#_Asp.net Core 2.1_Smtpclient - Fatal编程技术网

我们可以在.NetCore WebApi中沿c#放置JavaScript代码吗

我们可以在.NetCore WebApi中沿c#放置JavaScript代码吗,javascript,c#,asp.net-core-2.1,smtpclient,Javascript,C#,Asp.net Core 2.1,Smtpclient,我的asp.net核心web Api中有一种方法,用于角色发送电子邮件,使用SmtpClient。 消息正文是以下html字符串: @"<html> <head> <style> #modalHeader{ background-color:#6495ED; color:whit

我的asp.net核心web Api中有一种方法,用于角色发送电子邮件,使用SmtpClient。 消息正文是以下html字符串:

  @"<html>
         <head>
              <style>
                   #modalHeader{
                        background-color:#6495ED;
                        color:white;
                        text-align: center;
                        height:80px;
                       }  
                        .example_b {
                                      color: #fff !important;
                                      text-transform: uppercase;
                                      text-decoration: none;
                                      background: #60a3bc;
                                      padding: 20px;
                                      border-radius: 50px;
                                      display: inline-block;
                                      border: none;
                                      transition: all 0.4s ease 0s;
                                     }
                                    .example_b:hover {
                                            text-shadow: 0px 0px 6px rgba(255, 255, 255, 1);
                                            -webkit-box-shadow: 0px 5px 40px -10px rgba(0,0,0,0.57);
                                            -moz-box-shadow: 0px 5px 40px -10px rgba(0,0,0,0.57);
                                            transition: all 0.4s ease 0s;
                                            }
                                </style>
                            </head>
                      <body>
                        <p>Bonjour,<br> 
                            Afin d’authentifier votre connexion sur le système de prise de rendez-vous à distance de la " + Structure + @" Nous vous invitons à  confirmer votre mail en cliquant sur ce lien 
                         </p>
                    <div style='border:1px solid black'>
                          //<div id='modalHeader'>Confirmation d'Email</div>
                            //<br>
                                //<br>
                            <div id='modalBody'>
                              <div class='button_cont' align='center'>
                                <a class='example_b' href='" + url + "' target='_blank' rel='nofollow noopener'>Confirmer Votre Email</a>" +
                                "</div> </div> <br/> </div> </body> </html>";
@”
#模头{
背景色:#6495ED;
颜色:白色;
文本对齐:居中;
高度:80px;
}  
.示例b{
颜色:#fff!重要;
文本转换:大写;
文字装饰:无;
背景:公元前60年;
填充:20px;
边界半径:50px;
显示:内联块;
边界:无;
转换:所有0.4s到0;
}
.示例_b:悬停{
文本阴影:0px 0px 6px rgba(255,255,255,1);
-网络工具包盒阴影:0px 5px 40px-10px rgba(0,0,0,0.57);
-moz盒阴影:0px 5px 40px-10px rgba(0,0,0,0.57);
转换:所有0.4s到0;
}
你好,
在“结构”+“不可侵犯的理性”的距离上,作者在系统价格上的联系,在客户上的确认人

//确认电子邮件 //
//
" + “
”;
正如您所见,我正在使用a href触发对服务中另一个方法的调用,问题是每次单击按钮时它都会向我打开一个空白页面,因此解决方案是使用javascript向按钮添加一个事件

我的问题是如何将Js添加到asp.NETCore2.1中的c#代码中?
仅仅在html标记中添加脚本标记就可以让JS完成工作吗?

你不能在电子邮件中执行javascript。这在90年代和2000年代初曾经是可能的,但现在已经不可能了。

如果您检查电子邮件中的元素,您确定看到了正确的url吗? 如果是,也许值得尝试检查一封电子邮件中的href链接。我当时检查了一下,看到了这样的情况:
这可能值得一试…

删除目标如何=“U blank”?删除目标仍会在相同模式的电子邮件中单击按钮后打开一个空白页那么有什么替代方案?我们无法链接html内容messageURL跟踪链接的事件