小编Ana*_*and的帖子

如何使用 Microsoft.Data.SqlClient Version=4.0.0 修复“目标主体名称不正确”错误

升级后Microsoft.Data.SqlClient Version=4.0.0出现错误:

已成功与服务器建立连接,但登录过程中出现错误。(提供程序:SSL 提供程序,错误:0 - 目标主体名称不正确。

我查找了重大更改https://github.com/dotnet/SqlClient/pull/1210,然后Encrypt=False在连接字符串中进行设置,但是错误仍然相同。

仅通过恢复到错误才消失2.0.1

有人可以建议如何解决该问题吗4.0.0

sql-server sqlclient

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

删除 HttpParams 中的空参数

我有一个标准对象,它的某些属性可以为空,如果我不做任何事情,查询字符串包括那些&p=undefined不受欢迎的,因为在 WebApi 中,这些来自"null"而不是null 因此在 Angular 客户端中给出

      return this._http
          .get<ExposureDifference[]>(AppSettings.ExposureRunDataQueryString, {params : <any>criteria, withCredentials: true}) 
          .catch<any, ExposureDifference[]>(this._trace.handleError("GET " + AppSettings.ExposureRunDataQueryString + criteria, []))
          .finally(() => this.isLoading = false);
Run Code Online (Sandbox Code Playgroud)

我可以得到查询字符串

http://localhost:63037/api/exposureRuns/data/?id=3&secsymb=undefined&fund=EL&esectype=SWAP_CDS
Run Code Online (Sandbox Code Playgroud)

有没有办法从查询字符串中排除未定义的参数?

query-string querystringparameter asp.net-core-webapi asp.net-core-2.0 angular

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

为什么CsvHelper无法从MemoryStream读取?

我正在尝试将上传的csv文件转换为对象,以便可以保存在db中。在控制器中,我正在使用CsvHeler

但是看起来这只有在我首先保存文件并从中读取时才有效。CsvHelper无法直接从内存流中处理文件内容。在第一个GetRecords下面的代码中返回空

    [HttpPost]
    [Route(ApiRoutes.EodVariationMarginPlugs)]
    public async Task<IActionResult> UploadPlugAsync(IFormFile filePayload)
    {

        if (filePayload.Length > 0)
        {

            using (var stream = new MemoryStream())
            {
                filePayload.CopyTo(stream);
                using (var reader = new StreamReader(stream))
                using (var csv = new CsvReader(reader))
                {
                    csv.Configuration.RegisterClassMap<EodVariationMarginPlugMap>();
                    csv.Configuration.MissingFieldFound = null;
                    var records = csv.GetRecords<EodVariationMarginPlug>().ToList(); // record count is 0
                    foreach (var p in records)
                    {
                        p.CreatedAt = DateTimeOffset.Now;
                        p.CreatedBy = HttpContext.User.Identity.Name;
                    }
                    await _repository.InsertPlugsAsync(records);
                }
            }

        var fileName = ContentDispositionHeaderValue
            .Parse(filePayload.ContentDisposition)
            .FileName.ToString().Trim('"');
            var path = Path.Combine(Path.GetTempPath(), fileName);
            using (var fileStream …
Run Code Online (Sandbox Code Playgroud)

csvhelper asp.net-core

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

在 Axios 中使用 NTLM 身份验证

我有一个使用 NTLM 身份验证的 WebApi,我正在尝试编写一个简单的 React UI 来从 API 获取数据,但得到 401。

axios.get('url').then(response => console.log(response));

如何将我的 Windows 凭据与 get 请求一起传递?

谢谢

reactjs axios

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

如何将 cURL 命令导入 POSTMAN

我正在尝试将cURL在命令提示符下工作的命令导入 POSTMAN

curl —cert-type p12 —v k -E "file.pem":"1111" --key "file.key" -v "https://blah" -H "Authorization: Bearer blahblahblah" -H "request-id: 123456" -H "someid: 999"

但我收到奇怪的消息,不知道如何解决 Error while importing Curl: Only the URL can be provided without an option preceding it. All other inputs must be specified via options.

有谁知道如何使这个导入工作?

curl postman

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

来自 EWS Nuget 的 NullReferenceException

我正在使用Exchange.WebServices.Managed.Api 2.2.1.2Nuget 包从 EWS 2016 发送电子邮件。有时我会收到下面给出的异常。电子邮件已发送并保存到“已发送邮件”文件夹中,因此看起来这不是服务器问题,并且似乎 Nuget 包以某种方式引发了此误导性错误。

有人遇到过这种情况吗?

    System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.WrapStream(Stream responseStream, String contentEncoding)
   at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetResponseStream(IEwsHttpWebResponse response)
   at Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.ReadResponse(IEwsHttpWebResponse response)
   at Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.InternalExecute()
   at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
   at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalCreateItems(IEnumerable`1 items, FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode, ServiceErrorHandling errorHandling)
   at Microsoft.Exchange.WebServices.Data.ExchangeService.CreateItem(Item item, FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode)
   at Microsoft.Exchange.WebServices.Data.Item.InternalCreate(FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode)
   at Microsoft.Exchange.WebServices.Data.EmailMessage.InternalSend(FolderId parentFolderId, MessageDisposition messageDisposition)
   at Microsoft.Exchange.WebServices.Data.EmailMessage.SendAndSaveCopy(WellKnownFolderName destinationFolderName)
   at Elliott.CollateralMgmt.Common.Email.Emailer.SendEws(Email email, Boolean isHtml, Dictionary`2 attachments) in …
Run Code Online (Sandbox Code Playgroud)

exchangewebservices

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

如何更改 Visual Studio 2017 中用于调试的默认浏览器?

我正在开发一个使用 Topshelf 作为服务托管的 ASP.NET Core Web API 项目。当我从调试器启动服务时,Swagger 页面出现在 Internet Explorer 中。如何更改以便使用 Chrome 启动它?

windows-services asp.net-core visual-studio-2017

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

NLog 内部记录器的编程配置

任何人都可以帮助 NLog 内部记录器的编程配置吗?

我有各种目标,电子邮件目标不发送任何电子邮件,尽管它确实有日志记录规则。所以我希望通过启用内部日志来获得更多见解。

但是,我进行了编程配置,但没有找到任何在代码中设置内部记录器的资源。

c# nlog

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

ASP.Net core 2.0 Web API 中的 Cookie 身份验证

我正在尝试在 ASP.Net Core 2.0 Web API 中使用基于 cookie 的身份验证,并尝试使用以下代码激活它。登录页面托管在与应用托管的域不同的域中。我已经向[Authorize]控制器添加了属性。

在启动时,我可以看到在调试器中调用的服务代码。

我的期望是,当我的 web 客户端使用 web api 服务时,中间件将检测到该标头没有 cookie 并将客户端重定向到登录页面。但是我可以自由调用控制器。

    public void ConfigureServices(IServiceCollection services)
    {
            services.AddCors(options => options.AddPolicy("AllowAll",
            builder => builder.SetIsOriginAllowed(s => true)
                .AllowAnyHeader()
                .AllowAnyMethod()
                .AllowCredentials()));

        services.TryAddTransient<CorsAuthorizationFilter, CorsAuthorizationFilter>();

        services.AddSwaggerGen(c =>
        {
            c.OperationFilter<FileOperationFilter>();
            c.SwaggerDoc("v1", new Info
            {
                Title = "Collateral Management API",
                Version = "v1"
            });
        });

        services.AddMvcCore(options =>
            {

                options.Filters.Add(new CorsAuthorizationFilterFactory("AllowAll"));
                var policy = new AuthorizationPolicyBuilder()
                    .RequireAuthenticatedUser()
                    .Build();
                options.Filters.Add(new AuthorizeFilter(policy));
            })
            .AddApiExplorer()
            .AddJsonFormatters(s => s.NullValueHandling = NullValueHandling.Ignore);

        services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(auth => …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-web-api asp.net-core

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

如何使用ASP.Net核心ModelMetadata属性

[Table("LegalEntity")]
[ModelMetadataType(typeof(LegalEntityMeta))]
public class LegalEntity : Entity<long>
{
}

public class LegalEntityMeta
{
    [JsonProperty(PropertyName = "LegalEntityId")]
    public long Id { get; set; }

    [JsonProperty(PropertyName = "LegalEntityName")]
    public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

在Startup.cs中...

        services
            .AddCors(options =>
            {
                options.AddPolicy("CorsPolicy",
                    builder => builder.AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader()
                        .AllowCredentials());
            })
            .AddAutoMapper(typeof(Startup))
            .AddMvcCore()
            .AddJsonFormatters()
            .AddApiExplorer();
Run Code Online (Sandbox Code Playgroud)

我的期望是看到具有属性legalEntityId和legalEntityName的json,但生成的json具有id和name作为属性。有人可以帮助我如何更改json属性吗?谢谢阿南德

json.net data-annotations asp.net-core-2.0

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