我如何下载(.exe根路径中的文件)和从Angular 4(我是Angular4和typescript的新手)和Web API上传文件.我搜索了这个,但找不到解决方案.你能帮忙吗?这是我找到的链接.
谢谢Victor.A
我正在尝试运行我的应用程序,但它遇到以下错误:
System.NotSupportedException HResult = 0x80131515 Message = IDX10634:无法创建SignatureProvider.算法:'[PII默认隐藏.将IdentityModelEventSource.cs中的'ShowPII'标志设置为true以显示它.]',SecurityKey:'[PII默认隐藏.将IdentityModelEventSource.cs中的'ShowPII'标志设置为true以显示它.]'不受支持.
哪里
算法是RS256
它坚持执行这条指令: var sectoken = tokenHandler.CreateToken(tokenDescriptor);
这是什么意思?我的代码出了什么问题?我怎么解决这个问题?
这是我的代码:
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;
//...
public class TokenManager
{
private string unencoded_key = "CaptainDeadpool";
private string encoded_key = "CaptainDeadpool";
//...
public TokenManager()
{
var plainTextBytes = Encoding.UTF8.GetBytes(unencoded_key);
encoded_key = Convert.ToBase64String(plainTextBytes);
}
public string CreateFromUsername(string usr, int? timer)
{
if (timer == null) { timer = 30; }
double timeadd = Convert.ToDouble(timer);
var secret = Convert.FromBase64String(encoded_key);
var tokenHandler = new JwtSecurityTokenHandler();
var …Run Code Online (Sandbox Code Playgroud) 这是我的代码,给出错误无法读取属性标题undefined.
父组件
import { Child } from './child.component';
@Component({
selector: 'parent',
})
export class ParentComponet implements OnInit, AfterViewInit {
constructor(){}
@ViewChild(Child) child: Child;
ngAfterViewInit(){
console.log("check data", this.child.title)
}
}
Run Code Online (Sandbox Code Playgroud)
和儿童组件是.
@Component({
selector: 'child',
})
export class ChildComponet {
public title = "hi"
constructor(){}
}
Run Code Online (Sandbox Code Playgroud)
routing.module.ts就像
{
path: "",
component: ParentComponent,
children: [
{
path: '/child',
component: ChildComponent
}
]
}
Run Code Online (Sandbox Code Playgroud)
并且给出了错误
ERROR TypeError: Cannot read property 'title' of undefined(…)
Run Code Online (Sandbox Code Playgroud) 我已经安装了新的AspNet Core 2.1 SDK - 现在已经正式使用了 - 但它仍未在Visual Studio 2017目标框架中列出,既包括现有项目也包括新项目:
正如我尝试过的类似主题所示:
PATH但它仍未列出.
阅读VS信息,我得到的Visual Studio版本是15.7.2(最新),而.NET框架版本是4.3.03056.
dotnet --info从Powershell 执行,我得到这个:

有谁知道如何解决这个问题?
visual-studio .net-core asp.net-core visual-studio-2017 asp.net-core-2.1
我想mat-table在 Angular 中放置一个删除按钮或 Angular 垃圾桶图标。我怎样才能实现它?我的工作表代码:
<mat-table #table [dataSource]="ELEMENT_DATA">
<ng-container cdkColumnDef="position">
<mat-header-cell *cdkHeaderCellDef fxFlex="40%">Position</mat-header-cell>
<mat-cell *cdkCellDef="let config" fxFlex="40%">{{config.position}}</mat-cell>
</ng-container>
<ng-container cdkColumnDef="name">
<mat-header-cell *cdkHeaderCellDef fxFlex="30%">Label</mat-header-cell>
<mat-cell *cdkCellDef="let config" fxFlex="30%">{{config.name}}</mat-cell>
</ng-container>
<ng-container cdkColumnDef="weight">
<mat-header-cell *cdkHeaderCellDef fxFlex="10%">Order</mat-header-cell>
<mat-cell *cdkCellDef="let config" fxFlex="10%">{{config.weight}}</mat-cell>
</ng-container>
<ng-container cdkColumnDef="symbol">
<mat-header-cell *cdkHeaderCellDef fxFlex="10%">Symbol</mat-header-cell>
<mat-cell *cdkCellDef="let config" fxFlex="10%">{{config.symbol}}</mat-cell>
</ng-container>
<mat-header-row *cdkHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *cdkRowDef="let config; columns: displayedColumns;"
(click)="editConfig(config.id)"></mat-row>
Run Code Online (Sandbox Code Playgroud) 我正在尝试将SignalR用于Asp Net Core 2.1,以便从控制器方法发送消息,该方法从Angular中的测试按钮触发调用.
我期望的行为是当我单击按钮时,我的服务调用控制器方法,该方法发送测试消息.然后,我将简单地记录消息.
我想在服务中管理它,以避免所有组件中的代码重复.
我已经阅读了一些关于在服务中使用SignalR的问题的例子(我已经使用了第二个解决方案)和本文以及官方文档,但即使应用这些概念它似乎也不起作用.
(所以,或者我绝对是以错误的方式应用它们,或者仍然缺少某些东西,但我找不到...
客户端成功连接到消息中心,如果我单击该按钮,该方法将被点击但我没有收到任何消息,而是在Chrome控制台中收到此警告:
警告:找不到名为"SendAsync"的客户端方法.
发送消息很好,问题就在于接收它们......
问题是:我做错了什么?是后端还是Angular端的错误?
我与你分享我的所有代码(调用控制器方法的按钮和服务是不相关的,因为对服务的调用很顺利):
> Startup.cs
public void ConfigureServices(IServiceCollection services)
{
//...
services.AddSignalR();
}
//...
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
//...
app.UseSignalR(routes =>
{
//...
routes.MapHub<MessageHub>("/messagehub");
//...
});
}
Run Code Online (Sandbox Code Playgroud)
> MessageHub.cs
public class MessageHub : Hub<ITypedHubClient>
{
public async Task SendMessage(string user, string message)
{
await Clients.All.SendAsync("ReceiveMessage", user, message);
}
}
public interface ITypedHubClient
{ …Run Code Online (Sandbox Code Playgroud) 我最近发布了我的 Ionic 4 Angular 应用程序作为网络应用程序和原生 Android 应用程序。
在原生 Android 应用程序中,除了保存下载的文件外,一切正常。
为了下载和保存文件,我一直使用file-savernpm 包如下(这是一个共享服务,每次我必须下载某些东西,从 PDF 到图像等...):
import { saveAs } from 'file-saver';
// ...
saveGenericFile(api: string, fileinfos: any, idFile: string): any {
let mediaType = 'application/pdf';
let fileName = '';
if (fileinfos != null) {
mediaType = fileinfos.contentType;
fileName = fileinfos.fileName;
}
const headers = this.base.commonHeader;
const url = this.baseUrl + api + '?id=' + idFile;
this.http.post(url, null, { headers, responseType: 'blob' }).subscribe(
(response) => {
// tslint:disable-next-line: prefer-const
let …Run Code Online (Sandbox Code Playgroud) 当使用ngModel从bumpDetail.name数组中获取属性get来使用冒号对象发出值时,我遇到了一些问题.
我在下面粘贴了我的代码片段.
有人可以帮我检查一下并告诉我哪里做错了吗?谢谢.
<p *ngFor="let bumpDetail of bumpDetail">
<input type="checkbox" id="device" [(ngModel)]={{bump.bumpDetail.name}}/>
<label for="device">{{bumpDetail.name}}</label>
</p>
Run Code Online (Sandbox Code Playgroud)
Bump[] = [{
"name": "bump_1",
"status": true
}, {
"name": "bump_2",
"status": false
}, {
"name": "bump_3",
"status": true
}]
Run Code Online (Sandbox Code Playgroud)
这是错误的.
解析器错误:插值({{}})其中表达式位于[{{bumpDetail.name}}]的第0列,在ng:///AppModule/SettingComponent.html@129:59("p*ngFor ="让bumpDetail的bumpDetail">
问题
如果我有某个实体的一组属性并且我正在遍历它们,有没有办法检查我在每个循环中迭代的反射类型属性是否配置.IsRequired()为其对应的实体?
例子
这个问题必须特别针对string属性,就像在大多数值类型中一样,如果 db 属性允许null值,那么它会被 EF Core 的 Scaffolding 操作映射为可空类型。
EG:可以为空的 int 被映射为int?,而不可为空的 int被映射为int。
如果我遍历该映射实体的属性,以检查我现在正在迭代的该属性是否为可空属性,我只需要检查是否myproperty.PropertyType == typeof(int?)但是...如果是string类型呢?
有没有办法检查它是否被标记为.IsRequired()属性?
到目前为止我的代码
在我的代码中,我有以下函数,它应该作为参数接收:
objectInstance:从我必须更新的实体派生的代理,我(必须)之前找到values:包含属性名称和我必须更新的属性的新值的字典。它可以填充所有属性,或者只填充其中的一些。properties:我之前通过反射找到的类的属性数组这个函数应该遍历属性数组,并且对于每个属性,如果新值包含在字典中,则在类的实例上设置其新值。
private static bool SetValues(Object objectInstance, Dictionary<string, object> values, PropertyInfo[] properties)
{
bool edited = false;
foreach (var item in values)
{
var temp = properties.Where(w => w.Name.ToLower() == item.Key.ToLower()).FirstOrDefault();
if (temp != null)
{
edited …Run Code Online (Sandbox Code Playgroud) angular ×5
c# ×3
typescript ×3
asp.net-core ×2
javascript ×2
.net-core ×1
angular6 ×1
capacitor ×1
html ×1
ionic4 ×1
jwt ×1
lazy-loading ×1
mat-table ×1
ngmodel ×1
signalr ×1