我使用jQuery
该POST
方法并使用该方法发送数据.但在服务器方法中,值不会到来.可能是什么错误?
客户
$.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)
固定 非常感谢大家.我理解我的错误.我为此修复了客户端和服务器代码:
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) 我正在以编程方式更改表单“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) 从Visual Studio启动时,ASP.NET CORE应用程序的地址为https:// localhost:44313 /。要测试性能,您需要建立一条隧道。我使用ngrok和命令:
ngrok http -host-header = localhost 44313
但这不适用于https。
谁能分享一个可行的例子?
我想在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) 如何使系列颜色与数据颜色相同?
在示例中,“不平衡”数据为红色,但系列为蓝色。
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) asp.net-core ×3
c# ×2
ajax ×1
angular ×1
asp.net ×1
highcharts ×1
https ×1
javascript ×1
jquery ×1
ngrok ×1
post ×1
typescript ×1