小编Amn*_*mna的帖子

浏览器多个选项卡中的不同连接

为什么 SignalR 在浏览器的多个选项卡中为同一登录用户建立不同的连接。有没有办法为在同一浏览器中打开的所有选项卡建立一个连接。从连接我的意思是 SignalR 中用户的 connectionID。

signalr signalr-hub signalr.client

7
推荐指数
1
解决办法
7139
查看次数

SmtpClient - 什么是适当的寿命?

我正在创建Windows服务,每5分钟发送一批电子邮件.

我想每5分钟发送一批10-100封电子邮件.这是极端的边缘情况.批次每5分钟发送一次,通常包含最多10封电子邮件.

我正在使用System.Net.Mail命名空间中的SmtpClient.

什么是SmtpClient对象的适当生命周期?每次发送批次时我应该创建一个吗?或者我应该在服务启动时创建一个并且永远不会丢弃它?

.net c# email service

7
推荐指数
2
解决办法
2558
查看次数

更新Android OS版本6.0.2后,事件未触发

我有一个视频开始和结束事件在视频开始和完成时触发.它工作正常,直到我更新到三星Galaxy S5上的OS版本6.0.2.即使在Iphone浏览器上,它在chrome,firefox上运行良好,但在Android本机浏览器上却没有

码:

$(document.getElementById('movie')).on('fullscreenchange webkitfullscreenchange webkitbeginfullscreen webkitendfullscreen', (
  function (e) {
       $(document).off('fullscreenchange mozfullscreenchange MSFullscreenChange');
       $scope.onFullScreenChange(e.type);
 }));


if (document.exitFullscreen) {
            document.exitFullscreen();
        } else if (document.webkitExitFullscreen) {
            document.webkitExitFullscreen();
        } else if (videoElement.exitFullscreen) {
            videoElement.exitFullscreen();
        } else if (videoElement.webkitExitFullscreen) {
            videoElement.webkitExitFullScreen();
        } else if (document.cancelFullScreen) {
            document.cancelFullScreen();
        } else if (document.mozCancelFullScreen) {
            document.mozCancelFullScreen();
        } else if (document.msExitFullscreen) {
            document.msExitFullscreen();
   }
Run Code Online (Sandbox Code Playgroud)

javascript jquery android

6
推荐指数
0
解决办法
100
查看次数

创建具有可重用性的 CSOM ClientContext,如单例模式

我在使用ClientContext 的不同用户操作上调用了多种方法。在每个方法执行上创建它会导致性能问题。

因此,我将其添加为可重用性的静态变量,性能平均提高了 5 秒,但随后在某些方法中,它开始在ExecuteQuery()上出现“版本冲突”的随机问题。但是如果我删除静态和空检查,那么它每次都会刷新并且性能成为一个问题

有什么方法可以创建这个或至少不是每次调用的一个时间对象?ClientContext 的默认过期时间是多少?

创建 ClientContext 对象的代码:

    public class SPConnection
    {
    public static ClientContext SharepointClientContext { get; set; }
    public static ClientContext GetSharePointContext()
    {
        try
        {
            if (SharepointClientContext == null)
            {
                string appId = System.Configuration.ConfigurationManager.AppSettings["appId"];
                string appSecret = System.Configuration.ConfigurationManager.AppSettings["appSecret"];
                string siteUrl = System.Configuration.ConfigurationManager.AppSettings["siteUrl"];

                var authManager = new OfficeDevPnP.Core.AuthenticationManager();
                using (ClientContext clientContext = authManager.GetAppOnlyAuthenticatedContext(siteUrl, appId, appSecret))
                {
                    SharepointClientContext = clientContext;
                    return clientContext;
                }
            }
            else
                return SharepointClientContext;
        }
        catch (Exception ex)
        { …
Run Code Online (Sandbox Code Playgroud)

c# sharepoint sharepoint-clientobject csom clientcontext

6
推荐指数
1
解决办法
507
查看次数

如何为窗口小部件按钮指定单独的工具栏组?

默认情况下,CKEditor将小部件按钮放在工具栏的"插入"组中.我想在工具栏上为我的小部件按钮指定一个自定义组.我怎样才能做到这一点?

widget toolbar ckeditor

5
推荐指数
1
解决办法
508
查看次数

不显示验证摘要消息第一次MVC

我正在使用MVC Identity For Login和MVC Validation For Required Fields,我不想第一次显示错误消息.只有在用户点击提交按钮时才会显示.但是由于页面每次都会发布到ActionResult,所以它也向我展示了验证.什么是不在页面加载时第一次显示消息的方法.我已经使用此代码来清除消息,但每次都清除它

在此输入图像描述

public ActionResult Login(LoginModel model)
{
if (!ModelState.IsValid)
{
       return View("Login");
}
foreach (var key in ModelState.Keys)
{
   ModelState[key].Errors.Clear();
}
}
//Model
 public class LoginModel
{

    [Required]
    [DataType(DataType.EmailAddress)]
    [Display(Name = "Email")]
    public string Email { get; set; }

    [Required]
    [DataType(DataType.Password)]
    [Display(Name = "Password")]
    public string Password { get; set; }
   }

  //HTML
  @using (Html.BeginForm())
    {
        @Html.ValidationSummary("")
        @Html.TextBoxFor(model => model.Email, new { maxlength = "45", placeholder = "User Email" })
        @Html.PasswordFor(model => model.Password, new …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc asp.net-mvc-4 asp.net-identity

3
推荐指数
1
解决办法
2906
查看次数

如何在 C# 中将 JSON 数据保存到 SQL 服务器数据库?

我正在使用突触支付 API,作为回报,我得到了一些回应。我想将该响应保存在 SQL 数据库中。

我为此创建了类。

下面是获取响应的代码

 var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://sandbox.synapsepay.com/api/v2/user/create");
            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method = "POST";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = "{\"email\":\"aaaanikuaaaanjaa@synapsepay.com\"," +
                              "\"fullname\":\"nik\"," +
                              "\"phonenumber\":\"111\"," +
                              "\"ip_address\":\"1.1.1.1.1\"," +
                              "\"password\":\"123123123\"," +
                              "\"client_id\":\"1111111111111111\"," +
                              "\"client_secret\":\"2222222222222222222\"}";

                streamWriter.Write(json);
                streamWriter.Flush();
                streamWriter.Close();
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
            }
        }
Run Code Online (Sandbox Code Playgroud)

我的 Json 响应

"{
\"expires_at\": \"1438381449\", 
\"expires_in\": \"5184000\", 
\"oauth_consumer_key\": \"tDOIKwdgJzSzbCQdpo9FGNCBV6cSDTAlJqdtBHg3\", \"refresh_token\": \"HxJWdwgrNchJHn5zviAO7nd141ALYXmSbNmuG5ZF\",
\"success\": true,
\"user_id\": 10212,
\"username\": \"1433197449c2630fc917ef4d2b846f\
"}"
Run Code Online (Sandbox Code Playgroud)

这是我的 …

.net c# sql-server asp.net json

3
推荐指数
1
解决办法
1万
查看次数

日期时间选择器验证开始日期应小于结束日期不起作用

Jquery日期时间选择器 验证开始日期应小于结束日期,并且我当前的代码不起作用

$(document).ready(function(){
  $("#startdate").datetimepicker({
    format:'Y-m-d H:i:s',
    onSelect: function (selected) {
      var dt = new Date(selected);
      dt.setDate(dt.getDate() + 1);
 $("#enddate").datetimepicker("option", "minDate", dt);
}                                 
});
  $("#enddate").datetimepicker({
    format:'Y-m-d H:i:s',
    onSelect: function (selected) {
      var dt1 = new Date(selected);
      dt1.setDate(dt1.getDate() - 1);
      $("#startdate").datetimepicker("option", "maxDate", dt1);
    }
  });
});
Run Code Online (Sandbox Code Playgroud)
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<label >Starts ON</label>
<input id="startdate" type="text" placeholder="YYYY-MM-DD HH:MM:SS" class="linecons-calendar"/>
<label>Ends ON</label>
<input id="enddate" type="text" placeholder="YYYY-MM-DD HH:MM:SS" class="linecons-calendar"/>
Run Code Online (Sandbox Code Playgroud)

我无法验证onselect功能是否被触发

jquery datetimepicker

3
推荐指数
1
解决办法
3万
查看次数

针对.net核心和.net框架4.6的Nuget包兼容性

我创建了一个nuget包,它支持.net框架和.net核心.但是其中的一个类只有.net核心可用的引用.我不需要在.net框架中使用该类

是否有任何属性或方法可用,在为.net framweork构建包时排除该类?

这就是我如何定位框架

<TargetFrameworks>netcoreapp2.0;netstandard2.0;net45;net46</TargetFrameworks>
Run Code Online (Sandbox Code Playgroud)

c# .net-framework-version nuget-package .net-core

3
推荐指数
1
解决办法
1080
查看次数

允许在 ApiControllers 上匿名应用

我正在使用 C# 和 .NET Framework 4.5.1 开发带有 Web Api 服务的 ASP.NET MVC 5 应用程序。

我已经启用<authentication mode="Windows" />Web.config,并添加对ASP.NET MVC控制器的情况如下:

[Authorize(Roles = @"MyDomain\MyRole")]
public class ReportController : Controller
Run Code Online (Sandbox Code Playgroud)

但我不需要 Windows 身份验证ApiController。如何启用对ApiControllers 的匿名访问?

asp.net asp.net-mvc active-directory windows-authentication asp.net-web-api

2
推荐指数
1
解决办法
3174
查看次数

在分配之前检查值是否为null

所以我正在创建一个新对象并从其他函数设置其属性.我需要在应用值之前检查它们是否为null.我该如何处理?

Customer = new Customer (
     name = requestCall.Name, 
     age = requestCall.Age.ofType<DateTime>().DOB
    )
Run Code Online (Sandbox Code Playgroud)

在申请之前,我如何检查requestCall.Age或requestCall.Name是否为空?

c#

0
推荐指数
1
解决办法
4847
查看次数