我刚刚从 2.1 升级到 .net core 3.1。
我更新了所有软件包,但出现以下无法解决的错误:
The type or namespace name 'DefaultHttpRequest' could not be found
The type or namespace name 'Internal' does not exist in the namespace 'Microsoft.AspNetCore.Http'
Run Code Online (Sandbox Code Playgroud)
我一直在上面使用:
using Microsoft.AspNetCore.Http.**Internal**;
private static async Task<UserInfo>
Uplpoad(byte[] buffer, FormFileCollection formFileCollection,
**DefaultHttpRequest defaultHttpRequest,**
Dictionary<string, StringValues> dictionary)
{
//some code
defaultHttpRequest.Form = new FormCollection(dictionary, formFileCollection);
//some code
}
public async void Test1Up()
{
//some code
var defaultHttpContext = new DefaultHttpContext(featureCollection);
var defaultHttpRequest = new **DefaultHttpRequest**(defaultHttpContext);
//some code
}
Run Code Online (Sandbox Code Playgroud)
请参阅 ** 中突出显示的行中的错误 …
我的视图中有一个按钮,我希望根据某些条件禁用该按钮。以下是我的看法:
@{
var myCondition = false;
myCondition = //set condtion here
}
<input type="submit" value="Create" class=" btn btn-primary" />
Run Code Online (Sandbox Code Playgroud)
因此,根据 myCondition 我想禁用/启用我的按钮。
我可以这样做:
@if(myCondition)
{
<input type="submit" value="Create" disabled="disabled" class=" btn btn-primary" />
}
else
{
//enable it here
}
Run Code Online (Sandbox Code Playgroud)
在 .net core 中是否有任何优雅的方法可以做到这一点。我们可以在这里使用一些 htmlextensions 吗?如果有人可以给我一个例子。
感谢您的投入。
我在我的应用程序中使用 Dynamodb.net。
我有以下代码。
var creds = new BasicAWSCredentials(awsId, awsPassword);
var dynamoClient = new AmazonDynamoDBClient(creds,
awsDynamoDbRegion);
var context = new DynamoDBContext(dynamoClient);
List<ScanCondition> conditions = new List<ScanCondition>();
conditions.Add(new ScanCondition("Id", ScanOperator.Equal, myId));
var response = await context.ScanAsync<Data>(conditions).GetRemainingAsync();
return response;
Run Code Online (Sandbox Code Playgroud)
我的数据模型如下:
[DynamoDBTable("MyTable")]
public class Data
{
[DynamoDBHashKey]
public string Id{ get; set; }
public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我们将模型“数据”中的表名称编码为
[DynamoDBTable("MyTable")]
Run Code Online (Sandbox Code Playgroud)
我们怎么能不对此进行硬编码呢?是否可以在我的实际代码本身中应用表名称,而不是在模型中给出?
谢谢
我已将我的角度模块定义如下,并希望按照指南使用 VM。不确定我在这里做错了什么,但它在控制台中给了我错误:
未捕获的错误:没有模块:myApp
这是我的代码:
<div ng-controller="Ctrl">
Hello, {{vm.name}}!
</div>
Run Code Online (Sandbox Code Playgroud)
var app = angular.module('myApp');
app.controller('Ctrl', ['$scope', '$http',
function ($scope, $http) {
var vm = this;
vm.name = "John";
}]);
Run Code Online (Sandbox Code Playgroud)
这是我的jsfiddle:
在这里使用 .net core web api。
我的 api 中有一个端点:
[HttpPost("data")]
public async Task<IActionResult> PostData(List<string> udata)
{
JArray sets = new JArray();
try
{
sets = Helper.GetData(udata);
}
catch (Exception e)
{
return StatusCode(500, e.Message);
}
}
Run Code Online (Sandbox Code Playgroud)
在上面,我在我的助手“GetData”中调用一个自定义方法,它完成所有的处理和计算。为了使 Api 控制器干净,我将所有处理移至此辅助方法。
下面是我的助手类:
public static class Helper
{
public static BadRequestObjectResult GetMessage(string message)
{
return new BadRequestObjectResult(message);
}
public static JArray GetData(List<string> udata)
{
if(udata == null)
return GetMessage("Data is null");
//do some processing and calclulations here
//return BadRequest if some issue
}
} …Run Code Online (Sandbox Code Playgroud) 我的父组件有一个子组件:Child0 和 Display。
Child 0 有一个按钮,用于打开一个模式,用户可以在其中从列表中选择项目。显示组件只有一个标签和一些文本。
用户界面流程:
所选数据存储在服务中。
我在显示组件中显示数据时遇到问题。当我查看其中选定的数据时,ngOnInit它是空的,因为用户尚未选择任何内容。当选定的数据发生变化时,如何更新该组件?
主要应用程序组件
<div class="row">
<child0-app (onSelectedData)="getSelectedData($event)" [dataForm]="dataForm"></child0-app>
</div>
<div class="row">
<app-display></app-display>
</div>
Run Code Online (Sandbox Code Playgroud)
我的服务
public getSelectedData() {
return this.selectedData;
}
public setSelectedData(selectedData: any[]) {
this.selectedData = selectedData;
}
Run Code Online (Sandbox Code Playgroud)
网格组件
getCheckedItemList() {
this.checkedList = [];
for (let i = 0; i < this.data.length; i++) {
if (this.data[i].isSelected) {
this.checkedList.push(this.data[i].Name);
}
}
this.appService.setSelectedData(this.checkedList);
}
Run Code Online (Sandbox Code Playgroud)
显示组件
constructor(private service: AppService) {
this.selectedData = this.service.getSelectedData();
}
Run Code Online (Sandbox Code Playgroud)
---更新答案---
感谢@Vlad 帮助我解决这个问题。
对于访问此帖子的其他人。我使用下面的代码来订阅和取消订阅 …