鉴于以下尝试将数据发布到生成PDF文件的Web服务,PDF rocket(顺便说一句,这很棒).
我收到错误无效的URI:uri字符串太长
为什么有人会对POSTed数据施加任意限制?
using (var client = new HttpClient())
{
// Build the conversion options
var options = new Dictionary<string, string>
{
{ "value", html },
{ "apikey", ConfigurationManager.AppSettings["pdf:key"] },
{ "MarginLeft", "10" },
{ "MarginRight", "10" }
};
// THIS LINE RAISES THE EXCEPTION
var content = new FormUrlEncodedContent(options);
var response = await client.PostAsync("https://api.html2pdfrocket.com/pdf", content);
var result = await response.Content.ReadAsByteArrayAsync();
return result;
}
Run Code Online (Sandbox Code Playgroud)
我收到了这个荒谬的错误.
{System.UriFormatException: Invalid URI: The Uri string is …Run Code Online (Sandbox Code Playgroud) Microsoft在 Linux 上为 Ubuntu打包了.NET Core。我目前正在使用它。我现在想安装Json.NET,它指示我使用包管理器控制台并运行,
PM> Install-Package Newtonsoft.Json
Run Code Online (Sandbox Code Playgroud)
我想知道我是怎么做那个 Linux 的。我看到有一个Nuget CLI,但它似乎在 .NET Core 上不可用。此外,文档说
在 Mac 和 Linux 上,安装 Mono 4.4.2 或更高版本。
如何在 Linux 上简单地安装软件包?npm/cpan/pip/gem 的 .NET 等价物是什么?
当我运行时dotnet nuget,install命令似乎丢失了。
NuGet Command Line 4.3.0.5
Usage: dotnet nuget [options] [command]
Options:
-h|--help Show help information
--version Show version information
-v|--verbosity <verbosity> The verbosity of logging to use. Allowed values: Debug, Verbose, Information, Minimal, Warning, Error. …Run Code Online (Sandbox Code Playgroud) 我有以下字符串:
{"key1":"value1","key2":"value2,some other part of value2"}
Run Code Online (Sandbox Code Playgroud)
我可以使用以下长语法来分割它:
var s = someString.Split(new[] {"\",\""}, StringSplitOptions.RemoveEmptyEntries);
var firstEntryValue = s[0].Split(':')[1];
var secondEntryValue = s[1].Split(':')[1];
Run Code Online (Sandbox Code Playgroud)
由于这个字符串基本上是一个Dictionary<string,string>,我怎样才能将整个事物基本上拉成一行?
我见过这样的话:
var s = someString.Split(new[] {"\",\""}, StringSplitOptions.RemoveEmptyEntries)
.Select(p => p.Split(':'))
.ToDictionary(split => split[0], split => split[1]);
Run Code Online (Sandbox Code Playgroud)
但它抛出并索引越界错误.是否有一些类似的语法可行?