我想解决继承控制器上的接口的多个类的 IEnumerable 集合的依赖关系。
我想在应用程序启动期间解决以下依赖关系:
var notificationStrategy = new NotificationStrategy(
new INotificationService[]
{
new TextNotificationService(), // <-- inject any dependencies here
new EmailNotificationService() // <-- inject any dependencies here
});
Run Code Online (Sandbox Code Playgroud)
通知策略
public class NotificationStrategy : INotificatonStrategy
{
private readonly IEnumerable<INotificationService> notificationServices;
public NotificationStrategy(IEnumerable<INotificationService> notificationServices)
{
this.notificationServices = notificationServices ?? throw new ArgumentNullException(nameof(notificationServices));
}
}
Run Code Online (Sandbox Code Playgroud)
在 ASP.NET Core 中,在不使用任何外部依赖项或库的情况下,对 IEnumerable 类型的对象进行依赖项注入的最佳方式是什么?
我有一个字符串列表的列表,即Currency Code.
var currencyCode = new List<string>() { "USD", "SGD", "KWD", "BHD", "LYD" };
Run Code Online (Sandbox Code Playgroud)
我还有另一个复杂的对象。
var rate = new List<Rate>()
{
new Rate() { CurrencyName = "USD (SMALL)",CurrencyCode = "USD SMALL",BranchName="Branch1"},
new Rate() { CurrencyName = "SGD BIG",CurrencyCode = "SGD BIG",BranchName="Branch1"},
new Rate() { CurrencyName = "KUWAIT DINAR",CurrencyCode = "KWD",BranchName="Branch1"},
new Rate() { CurrencyName = "USD BIG (100,50)",CurrencyCode = "USD BIG",BranchName="Branch1"},
new Rate() { CurrencyName = "USD MEDIUM (10,20)",CurrencyCode = "USD MEDIUM",BranchName="Branch1"},
};
Run Code Online (Sandbox Code Playgroud)
我将在以下列表中找到匹配的货币:
var matchedCurrency = from …Run Code Online (Sandbox Code Playgroud) 这是我第一次尝试在我的 asp.net core 5.0 应用程序中运行 docker 映像。我在docker文件中添加了以下配置。
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["Shopping.Client/Shopping.Client.csproj", "Shopping.Client/"]
RUN dotnet restore "Shopping.Client/Shopping.Client.csproj"
COPY . .
WORKDIR "/src/Shopping.Client"
RUN dotnet build "Shopping.Client.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Shopping.Client.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Shopping.Client.dll"]
Run Code Online (Sandbox Code Playgroud)
wwwroot我正在尝试使用以下代码访问我的文件夹中的文件:
private async Task<T> ReadAsync<T>(string filePath)
{
using FileStream stream = …Run Code Online (Sandbox Code Playgroud) 我将vuejs应用程序托管在WWWROOTAsp.net Core 2.0 应用程序的文件夹内。
当我尝试使用以下网址运行应用程序时:
https://admin.myapp.com或https://admin.myapp.com/index,当在浏览器上点击https://admin.myapp.com时,应用程序应重定向到 ../index 但没有任何内容正在发生。他们在浏览器控制台上始终出现以下错误。
manifest.c93377026a31fd19d204.js:1 Uncaught SyntaxError: Unexpected token < vendor.ce0b0308730c78917196.js:1 Uncaught SyntaxError: Unexpected token < app.09cbf8437d50e73c0697.js:1 Uncaught SyntaxError: Unexpected token <
我正在应用程序的 Web 配置文件中重写 URL,如下所示。
Web Config在 wwwroot 文件夹之外。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="VueJs Routes" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(account)" negate="true" /> …Run Code Online (Sandbox Code Playgroud) 我试图oidc-client在角度应用程序中使用 with oppeniddict 但存在错误.well-known/openid-configuration。
错误说:
GET http://localhost:2987/.well-known/openid-configuration 400 (Bad Request)
Run Code Online (Sandbox Code Playgroud)
我在 dot-net core 5 应用程序中有 openiddict 实现。
然后我抓取 URLhttp://localhost:2987/.well-known/openid-configuration 并在浏览器中浏览它,我收到错误:
{
"error": "invalid_request",
"error_description": "This server only accepts HTTPS requests.",
"error_uri": "https://documentation.openiddict.com/errors/ID2083"
}
Run Code Online (Sandbox Code Playgroud)
我还从 Web 服务器设置中禁用了 SSL,如图所示:
我的启动ConfigureServices看起来像这样:
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ApplicationDbContext>(options =>
{
options.UseSqlServer(Configuration["ConnectionString"], sqlServerOptionsAction: sqlOptions =>
{
sqlOptions.MigrationsAssembly(typeof(Startup).GetTypeInfo().Assembly.GetName().Name);
});
options.UseOpenIddict();
});
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.Configure<IdentityOptions>(options =>
{
options.ClaimsIdentity.UserNameClaimType = Claims.Name;
options.ClaimsIdentity.UserIdClaimType = Claims.Subject;
options.ClaimsIdentity.RoleClaimType = Claims.Role;
});
services.AddOpenIddict() …Run Code Online (Sandbox Code Playgroud) 我想使用客户端凭据对 API 资源进行身份验证。
我已经能够成功生成令牌。
在发送 API 请求时,我记录了错误,它显示:
2021-06-10T00:47:19.1953056+05:45 [ERR] (OpenIddict.Validation.OpenIddictValidationDispatcher) The authentication demand was rejected because the token had no audience attached.
2021-06-10T00:47:19.1954307+05:45 [INF] (OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandler) "OpenIddict.Validation.AspNetCore" was not authenticated. Failure message: "An error occurred while authenticating the current request."
2021-06-10T00:47:19.1960031+05:45 [INF] (OpenIddict.Validation.OpenIddictValidationDispatcher) The response was successfully returned as a challenge response: "{
\"error\": \"invalid_token\",
\"error_description\": \"The specified token doesn't contain any audience.\",
\"error_uri\": \"https://documentation.openiddict.com/errors/ID2093\"
}".
2021-06-10T00:47:19.1960852+05:45 [INF] (OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandler) AuthenticationScheme: "OpenIddict.Validation.AspNetCore" was challenged.
Run Code Online (Sandbox Code Playgroud)
我的配置中缺少什么?使用客户端凭据授予类型通过 openiddict 保护 API 资源的正确方法是什么?
资源服务器启动配置: …
我正在制作一个带有折叠显示/隐藏的侧栏菜单。使用我当前的 css,折叠并不平滑,并且看起来很强力或者看起来有些奇怪。
我想要一张在关闭项目时能够平滑过渡的幻灯片。但就我而言,发生的情况是当某个项目已经打开并且单击下一个项目(打开)时。看起来切换正在被强制执行,并且列表的折叠似乎并不顺利。
对此有什么更好的方法,请提出一些更好的方法。
我不知道我的方法是否正确,或者我在这里遗漏了什么?
new Vue({
el: '#app',
methods: {
setActiveItemId(itemIndex) {
if (itemIndex === this.activeItemId) {
this.activeItemId = ''
return
}
this.activeItemId = itemIndex
}
},
data() {
return {
message: 'Hello Vue.js!',
activeItemId: '',
sideBar: [{
name: "Dashboard",
url: "/dashboard",
icon: "ti-world",
children: [{
name: "Buttons",
url: "/components/buttons",
icon: "fa-book",
},
{
name: "Social Buttons",
url: "/components/social-buttons",
icon: "icon-puzzle",
}
]
},
{
name: "Components",
url: "/components",
icon: "ti-pencil-alt",
children: [{
name: "Buttons",
url: "/components/buttons",
icon: …Run Code Online (Sandbox Code Playgroud)c# ×3
.net-core ×2
openiddict ×2
vue.js ×2
bootstrap-4 ×1
css ×1
docker ×1
dockerfile ×1
iis-8 ×1
linq ×1
vuejs2 ×1