小编mk_*_*_yo的帖子

javascript没有正确地将角度ui datepicker日期转换为UTC

我在我的项目中使用了角度ui datepicker(asp.net web api + angularjs).一切正常,但是当我试图将日期保存到Db时,它没有正确地将它转换为UTC格式并且导致1天(实际上是几个小时,但它也影响了一天).

例如,当我在datepicker中选择01/11/2014时:

Angularjs object:
Sat Nov 01 2014 00:00:00 GMT+0200 (FLE Standard Time)

In request: 
2014-10-31T22:00:00.000Z

In asp.net api controller:
{31-Oct-14 10:00:00 PM}
Run Code Online (Sandbox Code Playgroud)

Datepicker控制器:

app.controller('DatepickerCtrl', function ($scope) {
    $scope.today = function () {
        $scope.dt = new Date();
    };
    $scope.today();
    $scope.clear = function () {
        $scope.dt = null;
    };
    $scope.open = function ($event) {
        $event.preventDefault();
        $event.stopPropagation();

        $scope.opened = true;
    };
    $scope.format = 'dd/MM/yyyy';
    $scope.dateOptions = {
        'starting-day': 1
    };
});
Run Code Online (Sandbox Code Playgroud)

hnml:

<div class="form-group inputGroupContainer" ng-controller="DatepickerCtrl">
                    <label …
Run Code Online (Sandbox Code Playgroud)

javascript datepicker asp.net-web-api angularjs angular-ui

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

使用内存缓存时,Asp.Net MVC中的InvalidOperationException

我需要In-Memory Cache在我的网站上提出申请,.NetFramework 4.5.2但出现了以下例外情况:

Unity.Exceptions.ResolutionFailedException:'解决依赖关系失败,类型='Tranship.UI.Areas.Portal.Controllers.SearchResultController',名称='(无)'。发生以下异常:正在解决。异常是:InvalidOperationException-当前类型Microsoft.Extensions.Caching.Memory.IMemoryCache是​​一个接口,无法构造。您是否缺少类型映射?

我正在使用Asp.net MVC(不是Core)并使用Microsoft.Extensions.Caching.Memory version 1.1.2 这是我的CS文件:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tranship.Business.Core;
using Tranship.Business.Interface;
using Tranship.DataAccess.UnitOfWork;
using Tranship.Domain.Context;
using Tranship.Domain.Model;
using Tranship.DomainService.Interface;
using Tranship.ViewModel.Model;
using Tranship.ViewModel.Mapper;
using Tranship.ViewModel.Parameter;
using Microsoft.Extensions.Caching.Memory;

namespace Tranship.DomainService.Core
{
    public class ScheduleDomainService : IScheduleDomainService
    {
        private readonly IMemoryCache MemoryCache;
        private readonly string key = "TranshipMemoryCache";
        public BoundedContextUnitOfWork Context { get; set; }
        public IScheduleBiz ScheduleBiz { get; set; }
        public ScheduleDomainService(IMemoryCache memoryCache) …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc caching memorycache asp.net-core

11
推荐指数
1
解决办法
285
查看次数

.Net Core 3.1 - 使用 Microsoft Ilogger 接口为 Serilog 设置 ForContext

如何使用来自 的接口来ForContext使用 Serilog 记录器的方法?ILoggerMicrosoft.Extensions.Logging

这是代码:

private readonly ILogger<UserService> _logger;

//DI code here

....

//inside some method
_logger.ForContext("CorrelationId", correlationId); // Ilogger doesn't contain ForContext extension method 

_logger.LogInformation("message");
Run Code Online (Sandbox Code Playgroud)

我真的不想使用ILoggerSerilog 的接口,因为我不希望它是 Serilog 特定的并且它不是通用的。

c# logging serilog asp.net-core

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

ASP.NET Core 自定义中间件重定向到操作不起作用

我正在尝试使用自定义中间件来处理 404 错误:

app.Use(async (context, next) =>
{
    await next();
    if (context.Response.StatusCode == 404)
    {
        context.Request.Path = "/error/404";
        await next();
    }
});
Run Code Online (Sandbox Code Playgroud)

但是错误控制器中没有调用所需的操作:

[Route("error")]
public class ErrorController : Controller
{
    public ErrorController()
    {
    }

    [Route("404")]
    public IActionResult PageNotFound()
    {
        return View();
    }
}
Run Code Online (Sandbox Code Playgroud)

我已经检查过是否会像“http:\localhost\error\404”那样直接进行调用,是否会调用它

http asp.net-core asp.net-core-middleware asp.net-core-webapi

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

打字稿中的 openlayers 3 自定义控件

下面js代码为openlayers地图添加自定义控件

/**
 * Define a namespace for the application.
 */
window.app = {};
var app = window.app;


//
// Define rotate to north control.
//



/**
 * @constructor
 * @extends {ol.control.Control}
 * @param {Object=} opt_options Control options.
 */
app.RotateNorthControl = function(opt_options) {

  var options = opt_options || {};

  var anchor = document.createElement('a');
  anchor.href = '#rotate-north';
  anchor.innerHTML = 'N';

  var this_ = this;
  var handleRotateNorth = function(e) {
    // prevent #rotate-north anchor from getting appended to the url
    e.preventDefault();
    this_.getMap().getView().setRotation(0);
  }; …
Run Code Online (Sandbox Code Playgroud)

javascript typescript openlayers-3

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

在bootstrap验证器中手动设置有效性

是否可以在bootstrap验证器中手动将字段有效性设置为无效?

我在我的项目中使用角度js并希望使用日期范围验证.

"max-date"属性工作正常,除非我手动输入日期,这就是我想在控制器中重新验证字段并手动设置字段有效性的原因.

HTML:

    <div class="form-group inputGroupContainer" ng-controller="DatepickerCtrl">
        <label for="date">Date of Birth</label>
        <p class="input-group">
            <input type="text" name="date1"  placeholder="DD/MM/YYYY" class="form-control"  ui-date="{dateFormat: 'dd/MM/yyyy'}" ui-date-format="dd/MM/yyyy" datepicker-popup="{{format}}" ng-model="user.Personal.BirthDate" max-date="currentDate" is-open="opened" close-text="Close" />
            <span class="input-group-btn">
                <button type="button"   class="btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button>
            </span>
        </p>
    </div>
Run Code Online (Sandbox Code Playgroud)

angularjs控制器:

$scope.$watch('user.Personal.BirthDate', function (newValue, oldValue) {
                    if (newValue !== oldValue) {
                        if ($scope.user.Personal.BirthDate)
                            if ($scope.user.Personal.BirthDate.getTime() > new Date().getTime()) {
//set validity for "date1" to invalid
                            }
                        $($('#editPersonalForm')).bootstrapValidator('revalidateField', 'date1');
                    }
                });
Run Code Online (Sandbox Code Playgroud)

validation angularjs angular-ui

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