小编al.*_*val的帖子

ASP.NET Core 2,jQuery POST数据为null

我使用jQueryPOST方法并使用该方法发送数据.但在服务器方法中,值不会到来.可能是什么错误?

客户

$.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: "./AddTag",
    dataType: "json",
    data: "{'parentId':42,'tagName':'isTagName'}",
    success: function (response) {
        // ...
    }
});
Run Code Online (Sandbox Code Playgroud)

服务器

[HttpPost]
public JObject AddTag(int parentId, string tagName)
{
    dynamic answer = new JObject();
    List<LogRecord> logs = new List<LogRecord>();
    answer.added = fStorage.Tags.AddTag(parentId, tagName, logs);
    return answer;
}
Run Code Online (Sandbox Code Playgroud)

Brackpoint

铬

固定 非常感谢大家.我理解我的错误.我为此修复了客户端和服务器代码:

let tag = {
        "Id": 0,
        "ParentId": 42,
        "Name": isTagName
    };
$.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: "./AddTag",
    dataType: "json",
    data: JSON.stringify(tag),
    success: function …
Run Code Online (Sandbox Code Playgroud)

c# ajax jquery post asp.net-core

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

如何在 HTML 代码中访问 FormControl 值

我正在以编程方式更改表单“select”的值。

在表单字段中,您可以看到值已更改。但该元素"p"仍然是隐藏的。

如果您手动更改表单的值,元素“p”的可见性将正常工作。

预期结果:

The <p> tag should be visible if the value of `field1` FormControl is equal to `1`.
Run Code Online (Sandbox Code Playgroud)

请告诉我,可能是什么问题?

组件.html

<form [formGroup]="formGroup">
  <mat-form-field class="mb-4" fxFlex="100">
      <mat-select #field1 formControlName="field1" placeholder="Data type" required>
        <mat-option value="0" selected>Boolean</mat-option>
        <mat-option value="1">Int</mat-option>
        <mat-option value="2">Double</mat-option>
        <mat-option value="3">String</mat-option>
        <mat-option value="4">Byte array</mat-option>
        <mat-option value="5">Object</mat-option>
      </mat-select>
    </mat-form-field>
</form>

<p *ngIf="field1.value === '1'">Integer</p>

<button mat-raised-button color="primary" (click)="onClick()">Set 'Int'</button>
Run Code Online (Sandbox Code Playgroud)

组件.ts

export interface Item {
  value: string;
  viewValue: string;
}

@Component({
  selector: 'select-overview-example',
  templateUrl: 'select-overview-example.html',
  styleUrls: ['select-overview-example.css'],
})
export …
Run Code Online (Sandbox Code Playgroud)

typescript angular-material angular

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

asp.net核心应用程序的ngrok和https隧道

从Visual Studio启动时,ASP.NET CORE应用程序的地址为https:// localhost:44313 /。要测试性能,您需要建立一条隧道。我使用ngrok和命令:

ngrok http -host-header = localhost 44313

但这不适用于https。

谁能分享一个可行的例子?

https ngrok asp.net-core

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

ASP.NET Core 2没有配置身份验证处理程序来处理该方案

我想在ASP.NET Core 2应用程序中提供授权.在账户/登录中发送带有数据的模型后,在调用之后await Authenticate(user),我收到一条错误消息.我无法理解哪里缺乏描述.

Startup.cs

//ConfigureServices
services.AddAuthentication(options =>
{
    options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
    options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
    options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
}).AddCookie("TmiginScheme", options =>
{
    options.LoginPath = "/Account/Login";
    options.LogoutPath = "/Account/Logout";
    options.ExpireTimeSpan = TimeSpan.FromHours(1);
    options.SlidingExpiration = true;
});

//Configure
app.UseAuthentication();
Run Code Online (Sandbox Code Playgroud)

的AccountController

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Login(LoginModel model)
{
    if (ModelState.IsValid)
    {
        User user = null;
        Cryptex cryptex = new Cryptex();
        string password = cryptex.EncryptText(model.Password, "TMigin");

        // ???? user
        user = fStorage.Users.GetUserByLogin(model.Login);
        if (user != null)
        {
            if (string.Compare(user.Password, password) != …
Run Code Online (Sandbox Code Playgroud)

c# asp.net authorization asp.net-core

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

Highcharts sankey 图,系列颜色

如何使系列颜色与数据颜色相同?

在示例中,“不平衡”数据为红色,但系列为蓝色。

Highcharts.chart('container', {

    title: {
        text: 'Highcharts Sankey Diagram'
    },

    series: [{
            colors: ["#90CAF9", "#F44336", "#1565C0"],
        keys: ['from', 'to', 'weight'],
        data: [
            {name: "prop-1", color: "#90CAF9", from: "prop-1", to: "transition", weight: 0},
            {name: "prop-2", color: "#90CAF9", from: "prop-2", to: "transition", weight: 4.14},             
            {name: "imbalance", color: "#F44336", from: "imbalance", to: "transition", weight: 0.6},
            {name: "prop-3", color: "#1565C0", from: "transition", to: "prop-3", weight: 4.74},
            {name: "prop-4", color: "#1565C0", from: "transition", to: "prop-4", weight: 0},
        ],
        type: 'sankey',
        name: 'Sankey demo series' …
Run Code Online (Sandbox Code Playgroud)

javascript highcharts sankey-diagram

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