我想在使用C#Web Api后端在TypeScript中开发我的React应用程序时使用热重新加载.我使用.Net框架而不是Core,所以我需要使用IIS或IIS Express.我可以使用webpack dev server没有问题的前端热重新加载,但后来我无法访问API资源.我能做到吗?
我刚刚在我的应用程序中注意到一个非常奇怪的事情。我有一段代码,用于检查文件夹或任何子文件夹是否包含.xls文件而不是.xlsx. 这是因为我使用EPPluswhich 无法处理.xls文件。在运行Windows 10 Home下面代码的计算机上只返回.xls文件而不返回任何.xlsx文件。我现在尝试在一Windows 10 Pro台机器上运行相同的代码,并且代码也获取了.xlsx文件。我知道我只能.xls使用文件,Linq 但我仍然想知道为什么会发生这种情况。
var filePaths = Directory.GetFiles("C:\\xmlfiles", "*.xls", SearchOption.AllDirectories).ToList();
if (filePaths.Count > 0)
{
var files = string.Join(",", filePaths);
throw new Exception($"Folder contains .xls files which EPPlus can't handle. Please convert them first. Files: {files}");
}
Run Code Online (Sandbox Code Playgroud) 我已按照此处指定的文档使应用程序始终运行并启用Service Auto-start.对于配置,我使用了此处指定的文档,在此应用程序中,我使用的是Hangfire 1.5.3版.我在同一台服务器上运行了另外两个Hangfire应用程序,一个使用Hangfire v.1.4.1,另一个使用1.4.5.这两项工作都完美无瑕.每个应用程序都在它自己的应用程序池下运行,并且代码没有区别.
无效的应用程序会在端口号后添加GUID,如下图所示.这个应用程序有时不会自动启动,我认为它与两个服务器实例有关.
我知道Hangfire已经使用ServerName修改了一些内容,因为如果使用"BackgroundJobServerOptions"和"ServerName"变量,则会收到过时的消息:
"服务器ID现在是自动生成的,此选项不再有意义.将在2.0.0中删除."
有没有人经历过这个并设法解决它?
注意:我没有在任何应用程序中使用BackgroundJobServerOptions,我尝试重新启动服务器.
有效的两个应用程序:
我正在使用webpack捆绑我的js文件,因此通常我只能在Chrome中的源代码下看到一个大捆绑文件。但是,如果将a添加debugger;到我的.tsx文件中,则可以看到一个文件。我的问题是,是否可以让webpack在Chrome Source中输出所有文件,以便可以在那里浏览它们,如果我不想停止调试器,只需单击一行?
在下面的屏幕截图中,我想要一个文件夹Scripts/src,然后是我的所有文件。
样例代码:
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">
<title>App</title>
</head>
<body>
<div id="app"></div>
<script src="/Scripts/dist/bundle.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
index.tsx:
import * as React from "react";
import * as ReactDOM from "react-dom";
import * as ReactRouter from "react-router";
import * as ReactBootstrap from "react-bootstrap";
import { Test } from "./components/test";
ReactDOM.render(
<div>
<Test text="Well!" />
<Container />
</div>,
document.getElementById("app")
);
Run Code Online (Sandbox Code Playgroud)
test.tsx:
import …Run Code Online (Sandbox Code Playgroud) 我正在尝试将三个脚本从 Javascript 转换为 TypeScript。脚本可以在这个gist 中找到。但是,我确实留下了一个无法摆脱的错误。请注意,这是我的第一个 React 和 TypeScript 项目,所以我很容易错过一些明显的东西。我正在使用.tsx文件和 TypeScript 2.1。
在文件中: GoogleApiComponent.tsx
import * as cache from './ScriptCache'
...
componentWillMount() {
this.scriptCache = cache({ <--Error TS2349 here
google: GoogleApi({
apiKey: apiKey,
libraries: libraries
})
});
}
Run Code Online (Sandbox Code Playgroud)
给我这个错误:
Cannot invoke an expression whose type lacks a call signature. Type 'typeof "ScriptCache"' has no compatible call signatures.
Run Code Online (Sandbox Code Playgroud)
ScriptCache.tsx 看起来像这样:
let counter = 0;
let scriptMap = new Map();
export const ScriptCache = (function (global: any) {
return …Run Code Online (Sandbox Code Playgroud) 我正在使用具有以下设置的Webpack DevServer:
devServer: {
proxy: {
'*': {
target: 'https://localhost:44369',
secure: true
}
},
port: 8080,
host: '0.0.0.0',
hot: true,
https: false
}
Run Code Online (Sandbox Code Playgroud)
https://webpack.js.org/configuration/dev-server/#devserver-https
它可以正常工作,HTTP但是当我现在将代理切换到HTTPS我时,我开始出现错误。
在命令提示符下收到以下消息:
[HPM]尝试将请求/从localhost:8080代理到https:// localhost:44369 (UNABLE_TO_VERIFY_LEAF_SIGNATURE)(https://nodejs.org/api/errors.html#errors_common_system_errors)时发生错误
我试图将Node设置NODE_TLS_REJECT_UNAUTHORIZED为,0但这无济于事。
new webpack.DefinePlugin({
'process.env.NODE_TLS_REJECT_UNAUTHORIZED': 0
})
Run Code Online (Sandbox Code Playgroud)
有什么方法可以访问生成的证书CA并将其添加到“受信任的根证书颁发机构”?这会有所帮助还是我还需要更改其他内容?
如果我切换https到true相同的错误。
生成SSL证书
...
[HPM]尝试将请求/从localhost:8080代理到https:// localhost:44369 (UNABLE_TO_VERIFY_LEAF_SIGNATURE)(https://nodejs.org/api/errors.html#errors_common_system_errors)时发生错误
当我在Chrome中访问所需的资源时,我还会收到以下错误消息:
更新:
现在,我已将webpack-dev-server设置为使用与原始Web服务器(https:// localhost:44369)相同的证书。我已验证两者之间的Thumbprint和Serial number是相同的。
https://webpack.js.org/configuration/dev-server/#devserver-pfx
https: true,
pfx: fs.readFileSync(path.resolve(__dirname, "../Client.WebProxy/App_Data/Certificate/") + '\\localhost.pfx'),
pfxPassphrase: …Run Code Online (Sandbox Code Playgroud) 我正在做一个像这样的简单查询:
select * from MyTable
Run Code Online (Sandbox Code Playgroud)
这会导致以下错误:
执行批处理时出错。错误消息是:算术溢出
我可以运行select top 14 * from MyTable并且运行没有问题,但在第 15 个值时出现错误,select top 15 * from MyTable显示算术溢出错误。
int该表由数据类型为: 、float和 的列组成smallint。
我已确认错误不会发生在int或smallint列中,因此错误发生在float列中。
两个问题:
运行Microsoft SQL Server 2005 - 9.00.5057.00于Microsoft Windows Server 2003 R2 Standard Edition with Service Pack 2.
更新设计:
USE [myDB]
GO
/****** Object: Table [dbo].[MyTable] Script CMte: 12/10/2019 10:35:13 ******/
SET ANSI_NULLS ON
GO
SET …Run Code Online (Sandbox Code Playgroud) 我的编辑器中有以下代码:
@page "/editor"
@using Markdig;
<div class="row">
<div class="col-6">
<textarea class="form-control" @bind-value="Body" @bind-value:event="oninput"></textarea>
</div>
<div class="col-6">
@if (!string.IsNullOrWhiteSpace(Body))
{
@((MarkupString)Preview)
}
</div>
</div>
@code {
public string Body { get; set; }
public string Preview => Markdown.ToHtml(Body);
}
Run Code Online (Sandbox Code Playgroud)
它适用于除桌子之外的所有东西。我已经尝试过应该支持的管道表和网格表,但我无法让它们渲染。我究竟做错了什么?
https://github.com/xoofx/markdig
https://github.com/xoofx/markdig/blob/master/src/Markdig.Tests/Specs/PipeTableSpecs.md
https://github.com/xoofx/markdig/blob/master/src/Markdig.Tests/Specs/GridTableSpecs.md
降价:
# Header
Text
- List item 1
- List item 2
+---------+---------+
| This is | a table |
a | b
-- | -
0 | 1
Run Code Online (Sandbox Code Playgroud)
管道表在这里工作:
| A | 乙 |
|---|---|
| 0 | 1 |
正如标题所示,我创建了一个新的 .NET 5 WorkerService,但是当我调用它时,HostingEnvironment.IsDevelopment()即使环境变量ASPNETCORE_ENVIRONMENT设置为 ,它也会返回 false Development。
Program.cs 看起来像这样:
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostContext, builder) =>
{
if (hostContext.HostingEnvironment.IsDevelopment())
{
builder.AddUserSecrets<Program>();
}
})
.ConfigureServices((hostContext, services) =>
{
var configuration = hostContext.Configuration;
var settings = new MyAppSettings();
configuration.GetSection("MyApp").Bind(settings);
services.AddSingleton(settings);
services.AddHttpClient();
services.AddHttpClient<MyAppHttpClient>();
services.AddHostedService<Worker>();
})
.ConfigureLogging(logging =>
{
logging.AddEventLog(eventLogSettings =>
{
eventLogSettings.SourceName = "MyAppBooker";
});
});
}
Run Code Online (Sandbox Code Playgroud)
环境变量在调试属性下设置,如下所示:
我可以确认环境变量也设置正确。
我正在遵循“开发中应用程序机密的安全存储”指南,代码来自那里。
我也尝试过设置NETCORE_ENVIRONMENT …