我在Package Release hub(VSTS)中创建了一个新的feed,安装了凭据,然后添加了包源.
现在,我使用Visual Studio 2015将Micrososft.Aspnet.mvc安装到项目中,但是它会出现以下错误:
Exception 'System.AggregateException' thrown when trying to add source
'https://mysite.pkgs.visualstudio.com/DefaultCollection/_packaging/MyLogUtils/nuget/v3/index.json'.
Please verify all your online package sources are available.
Run Code Online (Sandbox Code Playgroud)
我需要正常安装NuGet包,所以我从VSTS中删除了Feed.但问题仍然存在.如何解决这个问题?
visual-studio nuget nuget-package azure-devops azure-artifacts
我正在使用Identity Server 4和Implicit Flow,并且想要向访问令牌添加一些声明,新的声明或属性是"tenantId"和"langId".
我已将langId添加为我的范围之一,如下所示,然后通过身份服务器请求,但我也获得了tenantId.怎么会发生这种情况?
这是范围列表和客户端配置:
public IEnumerable<Scope> GetScopes()
{
return new List<Scope>
{
// standard OpenID Connect scopes
StandardScopes.OpenId,
StandardScopes.ProfileAlwaysInclude,
StandardScopes.EmailAlwaysInclude,
new Scope
{
Name="langId",
Description = "Language",
Type= ScopeType.Resource,
Claims = new List<ScopeClaim>()
{
new ScopeClaim("langId", true)
}
},
new Scope
{
Name = "resourceAPIs",
Description = "Resource APIs",
Type= ScopeType.Resource
},
new Scope
{
Name = "security_api",
Description = "Security APIs",
Type= ScopeType.Resource
},
};
}
Run Code Online (Sandbox Code Playgroud)
客户:
return new List<Client>
{
new Client
{
ClientName = "angular2client", …
Run Code Online (Sandbox Code Playgroud) c# jwt thinktecture-ident-server openid-connect identityserver4
有没有办法在ASP.NET Core中创建自定义属性,以验证一个日期属性是否小于模型中的其他日期属性ValidationAttribute
.
让我说我有这个:
public class MyViewModel
{
[Required]
[CompareDates]
public DateTime StartDate { get; set; }
[Required]
public DateTime EndDate { get; set; } = DateTime.Parse("3000-01-01");
}
Run Code Online (Sandbox Code Playgroud)
我想尝试使用这样的东西:
public class CompareDates : ValidationAttribute
{
public CompareDates()
: base("") { }
public override bool IsValid(object value)
{
return base.IsValid(value);
}
}
Run Code Online (Sandbox Code Playgroud)
我发现其他SO帖子建议使用另一个库,但我更喜欢坚持ValidationAttribute,如果这是可行的.
我正在使用ASP.NET Core Web API
,我有多个独立的web api项目.在执行任何控制器的操作之前,我必须检查登录用户是否已经模仿其他用户(我可以从中获取DB
)并且可以将模拟用户传递Id
给actions
.
由于这是一段可以重复使用的代码,我想我可以使用中间件:
public class GetImpersonatorMiddleware
{
private readonly RequestDelegate _next;
private IImpersonatorRepo _repo { get; set; }
public GetImpersonatorMiddleware(RequestDelegate next, IImpersonatorRepo imperRepo)
{
_next = next;
_repo = imperRepo;
}
public async Task Invoke(HttpContext context)
{
//get user id from identity Token
var userId = 1;
int impersonatedUserID = _repo.GetImpesonator(userId);
//how to pass the impersonatedUserID so it can be picked up from controllers
if (impersonatedUserID …
Run Code Online (Sandbox Code Playgroud) c# middleware asp.net-core-mvc asp.net-core asp.net-core-webapi
我有一个简单的应用程序,其中一个组件需要来自url的某些参数.应用程序中只有一条路线:
const appRoutes: Routes =
path: 'hero/:userId/:languageId',component: HeroWidgetComponent }];
Run Code Online (Sandbox Code Playgroud)
在Index.html中,我在标题中有这个 <base href="/">
我正在使用webpack,并且在浏览url时,应用程序在开发环境中运行良好:http://localhost:4000/hero/1/1
.
但是,在构建用于生产的应用程序并获取分发文件时,请在IIS上托管该应用程序.尝试浏览同一个网址时出现以下错误:
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Run Code Online (Sandbox Code Playgroud)
如果我删除所有路由并只http:localhost:4200
在IIS上浏览:该应用程序工作正常.
我正在使用ASP.NET Core 1.0.1.我有以下内容
"Microsoft.AspNetCore.Mvc": "1.0.1"
用于开发控制器的类库 :using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace CoreAPIsLibrary.Controllers
{
[Route("api/[controller]")]
public class ValuesContoller : Controller
{
public string Get()
{
return "value";
}
// GET api/values/5
[HttpGet("{id}")]
public string Get(int id)
{
return "value";
}
// POST api/values
[HttpPost]
public void Post([FromBody]string value)
{
}
// PUT api/values/5
[HttpPut("{id}")]
public void Put(int id, [FromBody]string value)
{
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的类libray的project.json:
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNetCore.Mvc": "1.0.1",
"NETStandard.Library": "1.6.0" …
Run Code Online (Sandbox Code Playgroud) c# asp.net-mvc asp.net-core-mvc asp.net-core asp.net-core-webapi
我正在尝试将我的项目开发为跨平台.我用这种方式创建了几个类库:
但是,当我使用Entity Framework来构建我的数据库时,除了在Console应用程序中使用时,所需的nuget包没有安装.
类库引用NET标准:
那么为什么他们都在.NET Core下但引用了不同的库?它们都是跨平台还是仅使用.NET Core的控制台?在这种情况下我应该避免使用类库吗?
.net class-library console-application .net-core .net-standard
我正在使用测试组件'WelcomeComponent'的示例之一:
import { Component, OnInit } from '@angular/core';
import { UserService } from './model/user.service';
@Component({
selector: 'app-welcome',
template: '<h3>{{welcome}}</h3>'
})
export class WelcomeComponent implements OnInit {
welcome = '-- not initialized yet --';
constructor(private userService: UserService) { }
ngOnInit(): void {
this.welcome = this.userService.isLoggedIn ?
'Welcome ' + this.userService.user.name :
'Please log in.';
}
}
Run Code Online (Sandbox Code Playgroud)
这是测试用例,我正在检查'h3'是否包含用户名'Bubba':
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { UserService } from …
Run Code Online (Sandbox Code Playgroud) 我已经在本地机器(Windows 10)上的 IIS(版本 10)上成功发布了一个 ASP.NET Core 网站并浏览了它。
但是,当我将它部署在另一台 PC 上的 IIS 上(使用相同版本)时,它给出了HTTP 错误 500.19:
我使用的是相同的Web.config
,并IIS_IUSRS有两个虚拟目录和配置文件的权限。我还将应用程序池“IIS AppPool/MyPool”的权限添加到虚拟目录中。这是 web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\IdentityServer.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
什么是问题?
我是Redis的新手并使用VS 2015和ASP.NET Core应用程序(v 1.0),我安装了nugget包:
Install-Package StackExchange.Redis
Run Code Online (Sandbox Code Playgroud)
但是我无法将其注入并配置到我的服务中,没有RedisCache或" AddDistributedRedisCache "方法.
我该如何注射和使用它?
asp.net-core ×5
c# ×4
angular ×2
iis ×2
.net ×1
.net-core ×1
asp.net ×1
asp.net-mvc ×1
azure-devops ×1
http-error ×1
jasmine ×1
jwt ×1
middleware ×1
nuget ×1
redis ×1
unit-testing ×1
validation ×1