小编Nik*_*rov的帖子

Azure Docker Web 应用程序。停止站点 <站点名称>,因为它超出了交换使用限制

我已使用 Docker Compose 将我的多容器 Web 应用程序部署到 Azure。一个用于 Web 应用程序本身的容器和一个用于数据库的容器。该应用程序每 5 分钟运行一次作业。从日志中我可以看到该应用程序一直工作到今晚凌晨 2 点,然后它被停止并显示以下消息:

Stoping site <site> because it exceeded swap usage limits
Run Code Online (Sandbox Code Playgroud)

我真的不明白什么是交换使用限制以及应用程序停止的原因。当我再次连接到应用程序时,我发现容器是从头开始重新创建的:数据库是空的。我怎样才能找出问题所在?

azure docker

8
推荐指数
0
解决办法
1053
查看次数

Swagger is not generating swagger.json

I have the asp.net core MVC project and separate WebApi project in one solution. I'm adding the swagger following the documentation on github. Here is my Startup.cs of mvc project:

public void ConfigureServices(IServiceCollection services)
    {
        //...
        // Adding controllers from WebApi:
        var controllerAssembly = Assembly.Load(new AssemblyName("WebApi"));
        services.AddMvc(o =>
            {
                o.Filters.Add<GlobalExceptionFilter>();
                o.Filters.Add<GlobalLoggingFilter>();
            })
            .AddApplicationPart(controllerAssembly)
            .AddJsonOptions(options =>
            {
                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            });

        services.AddSwaggerGen(c =>
        {
            //The generated Swagger JSON file will have these properties.
            c.SwaggerDoc("v1", new Info
            {
                Title = "Swagger XML …
Run Code Online (Sandbox Code Playgroud)

c# swagger asp.net-core asp.net-core-2.1

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

粘贴图像时 Javascript clipboardData.items 和 clipboardData.files 为空

我正在尝试按照这篇文章从剪贴板中的 javascript 获取图像:https : //stackoverflow.com/a/6338207/6188783

document.onpaste = function (event) {
    console.log("paste triggered!");
    console.log("text: " + event.clipboardData.getData("text")); // shows text if it was pasted
    console.log("image: " + event.clipboardData.getData("image")); // always returns empty string p.s. I've also tried image/bmp and other formats 
    var items = (event.clipboardData || event.originalEvent.clipboardData).items;
    console.log(JSON.stringify(items)); // will give you the mime types
    for (index in items) {
        var item = items[index];
        if (item.kind === 'file') {
            var blob = item.getAsFile();
            var reader = new FileReader();
            reader.onload = …
Run Code Online (Sandbox Code Playgroud)

javascript clipboard

5
推荐指数
0
解决办法
2996
查看次数

实体框架核心。如何正确更新相关数据?

这个问题很常见,但我还是不明白如何正确更新相关实体?

我有以下代码:

    public async Task<bool> UpdateStepAssignedToLevelAsync(Step step, Guid levelId, int priority = -1)
    {
        var item = await this._context.StepLevels
            .Include(sl => sl.Step)
            .FirstOrDefaultAsync(x => x.StepId == step.Id && x.LevelId == levelId);
        if (item == null)
        {
            return false;
        }

        //this._context.Entry(item).State = EntityState.Detached;
        if (priority > -1)
        {
            item.Priority = priority;
        }

        item.Step = step;

        //this._context.StepLevels.Update(item);
        var rows = await this._context.SaveChangesAsync();
        return rows > 0;
    }
Run Code Online (Sandbox Code Playgroud)

当它运行时,我收到以下错误:

InvalidOperationException: The instance of entity type 'Step' cannot be tracked because another instance with …
Run Code Online (Sandbox Code Playgroud)

c# one-to-many sql-update entity-framework-core

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

Redux 工具包 + Typescript:extraReducers

我正在尝试将打字稿添加到我的react/redux 项目中。这是我的切片:

import { createSlice, createAsyncThunk, AnyAction, CaseReducer, PayloadAction } from '@reduxjs/toolkit';
export interface RequestStateBase {
    failed: boolean;
    executing: boolean;
    initialLoad: boolean;
    message: string | null;
    errors: any[]
}
const handlePending = (state: RequestStateBase) => {
    state.failed = false;
    state.executing = true;
    state.message = '';
}

const createCharacter = createAsyncThunk(
    'character/new',
    async (model: any) => characterClient.createCharacter(model)
);

const characterSlice = createSlice({
    name: "character",
    initialState: initialState,
    reducers: {
        cleanCharacterData: (state: CharacterState) => {
            //...
        },
        //...
    },
    extraReducers: builder => { …
Run Code Online (Sandbox Code Playgroud)

typescript redux redux-toolkit

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

asp.net core 3.1 SignalR:将复杂对象从javascript客户端传递到Hub

我试图将一个对象从客户端传递到集线器:在客户端上:

connection.invoke('MyMethod', {
                i: 1,
                a: 25
            });
Run Code Online (Sandbox Code Playgroud)

在集线器上:

        public async Task MyMethod(TestModel model)
        {
            // logic
        }
Run Code Online (Sandbox Code Playgroud)

模型:

public class TestModel
{
    [JsonProperty("i")]
    public double Min {get;set;}
    [JsonProperty("a")]
    public double Max {get;set;}
}
Run Code Online (Sandbox Code Playgroud)

在 MyMethod 中,模型不为 null,但值始终为 0。

我做错了什么?

javascript c# signalr asp.net-core asp.net-core-signalr

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