小编Ovi*_*Ovi的帖子

ASP.NET Core中的加密配置

随着web.config离开,在使用ASP.NET Core构建的Web应用程序的配置中存储敏感信息(密码,令牌)的首选方法是什么?

有没有办法自动获取加密的配置部分appsetttings.json

asp.net-mvc asp.net-core-mvc .net-core asp.net-core

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

aspnetcore(netcoreapp1.0)中System.Web.Security.Membership.GeneratePassword的替代方案

是否有替代System.Web.Security.Membership.GeneratePasswordin AspNetCore(netcoreapp1.0).

最简单的方法是使用一个Guid.NewGuid().ToString("n")足够长的密码,但它不是完全随机的.

asp.net asp.net-mvc asp.net-core asp.net-core-1.0 .net-standard-1.5

17
推荐指数
1
解决办法
5614
查看次数

Entity Framework Core - DefaultValue(true) 属性不起作用

在实体框架核心中设置数据库列的默认值的代码优先方法是什么?

尝试#1:在模型上使用该DefaultValue属性似乎不起作用

[DefaultValue(true)]
public bool ShowInReports { get; set; }
Run Code Online (Sandbox Code Playgroud)

运行迁移后,dotnet ef 5.0.1版本生成以下代码:

    migrationBuilder.AddColumn<bool>(
        name: "ShowInReports",
        table: "ParametersUsed",
        nullable: false,
        defaultValue: false);
Run Code Online (Sandbox Code Playgroud)

尝试#2:尝试定义中的值OnModelCreating无法识别该函数:

    modelBuilder.Entity<TableName>()
        .Property(t=> t.ShowInReports)
        .HasDefaultValue(true);
Run Code Online (Sandbox Code Playgroud)

错误:'PropertyBuilder<bool>' does not contain a definition for 'HasDefaultValue' and no accessible extension method 'HasDefaultValue' accepting a first argument of type 'PropertyBuilder<bool>' could be found (are you missing a using directive or an assembly reference?)

c# entity-framework entity-framework-core .net-core asp.net-core

16
推荐指数
1
解决办法
6642
查看次数

CosmosDb 计算不同的元素

是否有直接函数来计算 CosmosDb 查询中的不同元素?

这是默认计数:

SELECT value count(c.id) FROM c
Run Code Online (Sandbox Code Playgroud)

和不计其数的独特作品:

SELECT distinct c.id FROM c
Run Code Online (Sandbox Code Playgroud)

但这会返回一个错误的请求 - 语法错误: SELECT value count(distinct c.id) FROM c

怎么会countdistinct一起工作?

sql azure azure-cosmosdb

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

从扫描仪获取图像

如何在Vista上使用.NET(C#)从扫描仪获取图像?优选地,可以设置DPI.

市场上有一些控制器可以做到这一点,但它们看起来效果不佳.

c# image-scanner

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

从JavaScript或JQuery设置React输入字段值

如何以编程方式设置React生成的输入字段的值,使用vanilla JS还是JQuery?

我尝试过以下内容似乎没有任何效果.

$(obj).val('abc');
$(obj).attr('value', 'abc');
$(obj).keydown();
$(obj).keypress();
$(obj).keyup();
$(obj).blur();
$(obj).change();
$(obj).focus();
Run Code Online (Sandbox Code Playgroud)

我也试图模拟keyPress(如此处所示)事件,但它似乎也没有用.

simulateKeyPresses (characters, ...args) {
  for (let i = 0; i < characters.length; i++) {
    this.simulate('keyPress', extend({
      which: characters.charCodeAt(i),
      key: characters[i],
      keyCode: characters.charCodeAt(i)
    }, args));
  }
}
Run Code Online (Sandbox Code Playgroud)

javascript jquery reactjs

8
推荐指数
3
解决办法
5360
查看次数

循环依赖

考虑使用WinForms基于MVC模式的普通客户订单应用程序.视图部分增长太多(超过4000个文件),需要将其拆分为较小的文件.


对于此示例,我们将使用3个项目作为视图部分:

  • Main - 与其他2个项目有依赖关系.使用列表实例化表单.
  • 客户 - 有2种表格 - 客户列表和客户详细信息.
  • 订单 - 有2种形式 - 订单清单和订单详细信息.

在客户详细信息表单上还有该客户的订单列表.该列表是从OrdersController接收的,所以它没有问题.当用户选择订单时,列表将获得它的guid并将其作为对Order Details表单的引用传递.

这意味着我们需要在Customers项目中引用Orders Project. (1)

但是,在订单详细信息表格中,还有一个指向客户的链接.单击时,应打开"客户详细信息"表单.

这意味着我们需要在Orders项目中引用Customers Project. (2)

从(1)和(2)我们将在Orders和Customers项目之间存在循环依赖关系.


如何避免这种情况?某种插件架构?该项目已经开发出来,最佳解决方案将尽可能少地改变代码.

c# asp.net-mvc dependencies

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

iTextSharp Html到Pdf图像src

使用iTextSharp将html转换为pdf

public static MemoryStream CreatePdfFromHtml(
        string html, List<Attachment> attachments)
    {
        MemoryStream msOutput = new MemoryStream();

        using (TextReader reader = new StringReader(html))
        using (Document document = new Document())
        {
            PdfWriter writer = PdfWriter.GetInstance(document, msOutput);
            document.Open();

            foreach (var a in attachments)
            {
                var image = iTextSharp.text.Image.GetInstance(a.File);
                document.Add(image);
            }

            XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, reader);

            writer.CloseStream = false;
            document.Close();
            msOutput.Position = 0;
            return msOutput;
        }
    }
Run Code Online (Sandbox Code Playgroud)

html以这种方式包含几个嵌入的图像.这种方法是首选,因为相同的HTML是通过电子邮件发送LinkedResourcesAlternateView.

foreach (var a in attachments)
{
    //not production code
    html += string.Format("<img src=\"cid:{0}\"></img>", a.Id.ToString());
} …
Run Code Online (Sandbox Code Playgroud)

c# itextsharp

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

Vue i18n - 使用 routerview 向 URL 添加语言环境

我正在使用 TypeScript 和 VueJS 的脚手架 AspNetCore 2.1 站点。我正在尝试将kazupon i18n插件与路由器视图集成。没有 URL 集成,它工作得很好。

我无法像http://localhost/en/producthttp://localhost/fr/product

这是最初的boot.ts,它使用VueI18n

import Vue from 'vue';
import VueRouter from 'vue-router';
import VueI18n from 'vue-i18n'

Vue.use(VueRouter);
Vue.use(VueI18n);

import { messages, defaultLocale } from './lang/i18n';

const i18n = new VueI18n({
    locale: defaultLocale,
    fallbackLocale: 'en',
    messages
})

const routes = [
        { path: '/', component: require('./components/home/home.vue.html') },
        { path: '/product', component: require('./components/product/product.vue.html') },
];

const router = new VueRouter({
    mode: 'history',
    routes: routes
}); …
Run Code Online (Sandbox Code Playgroud)

internationalization vue.js vue-router vuejs2

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

如果启用了Windows Update,请从.NET检查

有没有办法从.NET检查是否启用了Windows更新?

我想在每次登录我的应用程序时提示用户他们的计算机可能存在风险,并为他们提供指向Windows更新网站(或控制面板上的Windows更新应用程序)的链接.

它最好适用于XP,Vista和Windows 7.也许有一个注册表项或更好的API?

.net c# vb.net windows

5
推荐指数
2
解决办法
4842
查看次数

Telerik MVC Grid Master详细级联下拉列表

我在两个层面上使用了Master-detail Telerik MVC Grid.

  • 第一级包含客户下拉和一些misc数据.
  • 第二级包含在第一级链接到客户的汽车下拉和一些misc数据.

我现在使用外键列来显示汽车和客户的下拉列表.如何在第一级过滤第二个下拉列表?

码:

@(Html.Telerik().Grid<Models.ClientsModel>()
        .Name("Grid")
        .ToolBar(commands => commands.Insert().ButtonType(GridButtonType.ImageAndText))
        .DataKeys(keys => keys.Add(c => c.ClientLineID))
        .Columns(columns =>
        {
            columns.ForeignKey(o => o.ClientID, (System.Collections.IEnumerable)ViewBag.Client, "ClientID", "Name")
                                                   .Width(330)
                                                   .Title("Client");
            columns.Command(commands =>
                {
                    commands.Edit().ButtonType(GridButtonType.ImageAndText);
                    commands.Delete().ButtonType(GridButtonType.ImageAndText);
                }).Width(250);
        })
        .DetailView(car => car.ClientTemplate(

            Html.Telerik().Grid<Delta.Models.CarModel>()
                        .Name("Car_<#= ClientID #>")
                        .DataKeys(keys => keys.Add(c => c.LineID))
                        .ToolBar(commands => commands.Insert().ButtonType(GridButtonType.ImageAndText))
                        .DataBinding(dataBinding =>
                        {
                            dataBinding.Ajax()
                                .Select("_CarLineIndex", "Client", new { id = "<#= ClientID #>" })
                                .Insert("_CarLineCreate", "Client", new { id = "<#= ClientID #>" })
                                .Update("_CarLineUpdate", "Client")
                                .Delete("_CarLineDelete", "Client");
                        }) …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc telerik telerik-mvc telerik-grid

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

ConfigureServices中的不明确的调用services.AddOptions()(IServiceCollection服务)

加入后services.AddOptions()ConfigureServices(IServiceCollection services)下面的错误发生:

CS0121  
The call is ambiguous between the following methods or properties: Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.AddOptions(Microsoft.Extensions.DependencyInjection.IServiceCollection) and Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.AddOptions(Microsoft.Extensions.DependencyInjection.IServiceCollection)'
Run Code Online (Sandbox Code Playgroud)

码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

...

public void ConfigureServices(IServiceCollection services)
{
    ...
    services.AddOptions();
    ...
}
Run Code Online (Sandbox Code Playgroud)

这特别奇怪,因为模糊性是在相同的"方法或适当的"之间

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

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

sql server 2008 r2数据库降级

有没有办法降级已在SQL Server 2008 R2上创建的数据库,以便在旧版本的SQL Server 2008(RTM/SP1)上运行.

sql sql-server sql-server-2008

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