小编Lar*_*rén的帖子

jQuery UI可选 - 使多个选择默认

默认情况下我需要进行多项选择,因此用户无需按住ctrl.非常感谢一些帮助,谢谢.

jquery jquery-ui selectable

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

注入具有构造函数依赖项的记录器

我正在尝试重构一些代码,以通过startup.cs中的映射服务使用.NET Core依赖注入.我想在这里注入一个IRequestDatabaseLogger而不是新建它.但是它需要构造函数中的上下文.我怎样才能做到这一点?甚至没有DI框架甚至可能吗?

    public class ActionFilter : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            var requestDatabaseLogger = new RequestDatabaseLogger(context);
            long logId = requestDatabaseLogger.Log();

            context.HttpContext.AddCurrentLogId(logId);

            base.OnActionExecuting(context);
        }
   }
Run Code Online (Sandbox Code Playgroud)

c# dependency-injection asp.net-core

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

汇编版本不匹配?(.Net Core 2.0与.NET Standard 2类库)

所以我的解决方案编译但是当我运行它时,我在运行.NET 4.6.1的类库中遇到错误.

System.TypeLoadException:'无法从程序集'System.Data,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'加载类型'System.Data.Common.DbProviderFactories'.

有什么建议?

编辑:

完成错误:

$ exception {System.TypeLoadException:无法从程序集'System.Data,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'加载类型'System.Data.Common.DbProviderFactories'.在System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver.GetService(系统类型,对象键,Func 3 handleFailedLookup) at System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver.GetServices(Type type, Object key) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey键,Func 2 valueFactory) at System.Linq.Enumerable.SelectManySingleSelectorIterator2.MoveNext())System.Linq.Enumerable.ConcatIterator 1.MoveNext() at System.Linq.Enumerable.SelectManySingleSelectorIterator2.MoveNext()at System .Linq.Enumerable.ConcatIterator 1.MoveNext() at System.Linq.Enumerable.<OfTypeIterator>d__321.MoveNext()at System.Collections.Generic.List 1.AddEnumerable(IEnumerable1 enumerable)at System.Linq.Enumerable.ToList [TSource](IEnumerable 1 source) at System.Data.Entity.Infrastructure.DependencyResolution.InternalConfiguration.Lock() at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.<.ctor>b__1() at System.Lazy1.ViaFactory(LazyThreadSafetyMode mode)at System.Lazy 1.CreateValue 1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy( )System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.GetConfiguration()at System.Data.Entity.DbContext.InitializeLazyInternalContext(IInternalConnection internalConnection,DbCompiledModel model)at XYConfigurationModule.ConfigurationContainer..ctor(String nameOrConnectionString)} System.TypeLoadException

.net c# asp.net

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

从 Core 2.0 更新到 3.1.1 后响应正文为空

更新:如果我改变返回新的 OkObjectResult(token); 返回 Ok("test"); 那么它不是空的。

要使用 API,您必须调用 AuthenticateAsync,它会创建并返回一个令牌。

    [AllowAnonymous]
    [HttpPost]
    public async Task<IActionResult> AuthenticateAsync([FromBody]string apiKey)
    {
        return await StopwatchLogger.LogExecutionTime($"Authenticate user: {apiKey}", async () =>
        {
            EnsureValidLoginRequest(apiKey);

            //Validate user credentials
            AuthenticationInfo authenticationInfo = await _authenticationService.AuthenticateUser(apiKey);
            if (!authenticationInfo.IsAuthenticated)
            {
                throw new RestApiExceptionNoLogging(ErrorCode.AuthenticationInvalidApiKey, "");
            }

            //Login current user and get the created token with claims identifying current user
            Token token = _authenticationService.LoginApiUser(HttpContext, authenticationInfo.SystemUser);

            return new OkObjectResult(token);
        });
    }
Run Code Online (Sandbox Code Playgroud)

令牌创建正确,据我所知,一切都和以前一样,除了响应正文变空。不会抛出任何错误。

编辑:添加startup.cs

public class Startup
{
    private const string LogText = "An error occurred during …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core asp.net-core-webapi

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

使用 iTextSharp 将图像转换为 PDF 保留剪切路径

我们希望以编程方式将图像批量转换为 PDF。到目前为止,我们似乎将使用 iTextSharp,但我们在处理带有剪切路径的 JPG 图像时遇到了问题。我们在测试中使用以下代码:

using (FileStream fs = new FileStream(output, FileMode.Create, FileAccess.Write, FileShare.None))
{
    using (Document doc = new Document())
    {
        using (PdfWriter writer = PdfWriter.GetInstance(doc, fs))
        {
            doc.Open();
            iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(source);

            image.SetAbsolutePosition(0, 0);
            doc.SetPageSize(new iTextSharp.text.Rectangle(0, 0, image.Width, image.Height, 0));
            doc.NewPage();

            writer.DirectContent.AddImage(image,false); 

            doc.Close();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

JPG 图像中的剪切路径似乎只是被丢弃了。有没有办法保留剪切路径?此外,在调用 AddImage 时,有一个 InlineImage 选项,有人知道这是做什么的吗?

c# jpeg clipping itext itextsharp

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