我在Service Fabric Stateless ASP.NET Core应用程序中看到以下异常.
System.InvalidOperationException: Unable to resolve service for type 'System.String' while attempting to activate 'MyService'.
at Microsoft.Extensions.DependencyInjection.ServiceLookup.Service.PopulateCallSites(ServiceProvider provider, ISet`1 callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.Service.CreateCallSite(ServiceProvider provider, ISet`1 callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetResolveCallSite(IService service, ISet`1 callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetServiceCallSite(Type serviceType, ISet`1 callSiteChain)
Run Code Online (Sandbox Code Playgroud)
怎么能解决不了System.String?我该如何进一步调试?
dependency-injection .net-core azure-service-fabric asp.net-core
我想在我的控制器中将param作为可选项,但是swagger根据需要显示它.
我的控制器看起来像:
[HttpGet("{name}")]
[SwaggerResponse((int)HttpStatusCode.OK)]
[SwaggerResponse((int)HttpStatusCode.BadRequest)]
public async Task<IActionResult> GetPolicy(string name)
{
if (string.IsNullOrEmpty(name))
{
return BadRequest("Name is empty");
}
try
{
CRUDPolicyResponse crudPolicyResponse = await _managementOperations.CRUDPolicy(CRUDType.Read, name, null);
if (!crudPolicyResponse.OperationSucceeded)
{
return StatusCode((int)HttpStatusCode.BadRequest, crudPolicyResponse.Message);
}
if (crudPolicyResponse.FileMetadataPolicy == null)
{
return NotFound($"Policy name doesn't exists NAME: {name}");
}
return Ok(crudPolicyResponse.FileMetadataPolicy);
}
catch (Exception ex)
{
_log.Error("Error while trying to save file meta data policy", ex);
return StatusCode((int)HttpStatusCode.InternalServerError, ex);
}
}
Run Code Online (Sandbox Code Playgroud)
我试图像这样更改为默认值:string name = null但不工作/

所以名称字符串是必需的,我不能使用名称为空.
我试图通过这个解决方案来解决我的问题, 使得int可以为空
我怎么可以要求Access Token在邮差针对Azure的AD B2C租户?
我尝试从Run NowAzure门户网站中获取网址并将其放入,Auth Url但会产生以下错误:
更新
在Chris的回答之后,我现在已经超过了上述错误.我可以登录但仍然无法获取访问令牌:
AADB2C90085:该服务遇到内部错误.请重新进行身份验证,然后重试.相关ID:45c56d47-4739-465f-8e02-49ba5b3a1b86时间戳:2017-11-16 15:27:52Z
我正在尝试构建一种验证我的令牌的方法。我正在使用 Open Id Connect 授权代码流从 Azure Active Directory 检索我的令牌。我得到的令牌是access_token和id_token。我正在使用 .NET Core。
我的验证代码如下:
string stsDiscoveryEndpoint = "https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration";
var handler = new JwtSecurityTokenHandler();
ConfigurationManager<OpenIdConnectConfiguration> configManager = new ConfigurationManager<OpenIdConnectConfiguration>(stsDiscoveryEndpoint, new OpenIdConnectConfigurationRetriever());
OpenIdConnectConfiguration config = configManager.GetConfigurationAsync().Result;
try
{
TokenValidationParameters validationParameters = new TokenValidationParameters
{
ValidIssuers = new [] { "https://login.microsoftonline.com/tenantid/v2.0" },
ValidAudiences = new [] { "client-Id" },
ValidateAudience = true,
ValidateIssuer = true,
IssuerSigningKeys = config.SigningKeys,
ValidateLifetime = true
};
var tokenHandler = new JwtSecurityTokenHandler();
SecurityToken validatedToken = null; …Run Code Online (Sandbox Code Playgroud) 在 Azure AD 中使用客户端凭据流时,我可以定义自定义范围并让它们返回吗?
在我的实验中,我配置了 2 个 Azure AD 应用程序,一个用于 Web API,一个用于客户端(Web API 客户端 A)。我向 Web API 添加了一个范围,但是当通过客户端凭据流请求访问令牌时,没有返回该范围。
此外,它只允许我在使用.default范围时请求访问令牌,即api://web-api-client-credential-flow/.default.
我遇到了这个 UserVoice 项目:V2.0 Client Credentials Implement Scopes所以它似乎在客户端凭据流下的 Azure AD 中不支持范围?
如果没有返回,那么为我的 Web API 客户端 A 应用程序授予该范围的权限有什么意义?Web API 如何知道守护程序应用程序是否具有执行必要操作的范围?
看来我必须使用应用程序权限?
我想根据一些字符串值构建一个 Uri,但我想避免在调用时显示端口.ToString()。
var uriBuilder = new UriBuilder("http://www.google.co.uk/")
{
Path = "test"
};
Run Code Online (Sandbox Code Playgroud)
下面的代码输出http://www.google.co.uk:80/test而不是http://www.google.co.uk/test. 有没有办法不将端口包含在最终字符串中,或者我是否必须使用其中一种解决方法(例如new Uri(new Uri(baseUrl), relativePath)?
我正在尝试使用Sample Graph API应用程序来更改用户的密码,但我得到了:
调用Graph API响应时出错:
{
"odata.error": {
"code": "Authorization_RequestDenied",
"message": {
"lang": "en",
"value": "Insufficient privileges to complete the operation."
}
}
}
Run Code Online (Sandbox Code Playgroud)
图形API请求:
PATCH /mytenant.onmicrosoft.com/users/some-guid?api-version=1.6 HTTP/1.1
client-request-id: ffd564d3-d716-480f-a66c-07b02b0e32ab
date-time-utc: 2017.08.10 03:04 PM
Run Code Online (Sandbox Code Playgroud)
JSON文件
{
"passwordProfile": {
"password": "Somepassword1$",
"forceChangePasswordNextLogin": false
}
}
Run Code Online (Sandbox Code Playgroud)
我已经测试过更新用户displayName,并且工作正常.
{
"displayName": "Joe Consumer"
}
Run Code Online (Sandbox Code Playgroud)
AD应用程序权限
oauth-2.0 azure-active-directory azure-ad-graph-api azure-ad-b2c
我是Webpack和.NET Core 2 Angular SPA模板的新手.我正在尝试为整个网站创建一个全局样式表.我可以在布局视图中引用该样式以在主视图中呈现它,但是我失去了预渲染引擎的好处并且与WebPack捆绑(以及缩小).
Webpack文档说,为了包含需要向模块添加require(../ filepath)的静态CSS,但我没有看到在boot.browser.ts中执行此操作的方法.
我还在开始使用.NET核心,所以我的网站基本上只是带有Angular的OOB .Net Core 2模板.我现在在ClientApp/Styles/Global.css中保留我的全局样式表.谢谢你的时间.
我正在尝试获取 Autodesk Revit 文件中的一些数据,该文件只是皮肤下的 ZIP。我可以使用 7zip 进行解压,但我希望能够使用所有本机 PS 或 Windows 实现自动化操作。在将 RVT 文件重命名为 ZIP 后,我尝试了 Expand-Archive,但 Expand-Archive 有一个奇怪的错误。代码是
Expand-Archive -path:'C:\RevitVersionTest\22-PLUMB-CLR-RECTANGULAR.zip' -destinationPath:'C:\Revit Fam'
Run Code Online (Sandbox Code Playgroud)
错误是
新对象:使用“3”个参数调用“.ctor”时出现异常:“无法找到中央目录记录末尾。”
通过WebDeploy将.Net Core应用发布到服务器时,将使用创建一个Web.Config文件stdoutLogEnabled=false。这将覆盖我设置的服务器上的web.config stdoutLogEnabled=true。
我努力寻找如何设置stdoutLogEnabled发布前的默认值。在.Net framework应用程序上,我会在web.config文件中进行转换,但是,在.Net core中,我的解决方案中实际上没有web.config文件。
我试图找到有关如何设置该值的文档,但是它不存在,或更可能是我没有使用正确的搜索词。有人可以建议如何在web.config中设置默认值。
asp.net-core ×4
azure-ad-b2c ×2
oauth-2.0 ×2
.net-core ×1
access-token ×1
angular ×1
azure ×1
c# ×1
javascript ×1
msbuild ×1
postman ×1
powershell ×1
swagger ×1
unzip ×1
web-config ×1
webpack ×1