我正在将一个 .NET Core 2.x 控制台应用程序设置为 Windows 服务,并且需要根据环境加载一个 appsettings json 文件。我正在考虑使用标识环境的命令行参数启动服务。我怎样才能在 Visual Studio 中做到这一点?无论我在项目设置中设置什么,EnvironmentName 值始终为“Production”。
如何从命令行参数设置我的环境?
var hostBuilder = new HostBuilder()
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureAppConfiguration((hostingContext, config) =>
{
var env = hostingContext.HostingEnvironment;
config.AddCommandLine(args);
config.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: false, reloadOnChange: true);
config.AddEnvironmentVariables();
})
.ConfigureServices((hostContext, services) =>
{
//Inject additional services as needed
services.AddHostedService<JobRunner>();
});
Run Code Online (Sandbox Code Playgroud)
VS 2015社区版(在家),npm 3.10,Angular 2我试图在ASP.Net MVC 5应用程序中获取Angular2设置.我开始使用的模板使用了旧版本的Angular,因此我更新了包引用.
当我构建时,列表中的第一个错误是:
构建:无法找到"节点"的类型定义文件
之后还有许多其他错误,但我假设大多数是由于第一个问题.
这是package.json和typings.json
的package.json
{
"version": "1.0.0",
"name": "aspnet",
"private": true,
"scripts": {
"postinstall": "typings install",
"typings": "typings"
},
"dependencies": {
"@angular/common": "~4.0.0",
"@angular/compiler": "~4.0.0",
"@angular/core": "~4.0.0",
"@angular/forms": "~4.0.0",
"@angular/http": "~4.0.0",
"@angular/platform-browser": "~4.0.0",
"@angular/platform-browser-dynamic": "~4.0.0",
"@angular/router": "~4.0.0",
"angular-in-memory-web-api": "~0.3.0",
"systemjs": "0.19.40",
"core-js": "^2.4.1",
"rxjs": "5.0.1",
"zone.js": "^0.8.4",
"bootstrap": "^3.3.7"
},
"devDependencies": {
"@types/core-js": "^0.9.41",
"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"gulp-concat": "^2.6.1",
"gulp-tsc": "^1.3.1",
"gulp-typescript": "^3.1.6",
"path": "^0.12.7",
"typescript": "~2.1.0",
"typings": "~2.1.1"
}
}
Run Code Online (Sandbox Code Playgroud)
typings.json …
如何使用powershell设置扬声器音量?我在这里和其他地方的网上挖不到真正找到答案.
我想我必须在C#中编写包含Win32 API的东西,然后从我的powershell脚本中调用它.Win32 API将是其中之一
[DllImport("winmm.dll")]
public static extern int waveOutGetVolume(IntPtr hwo, out uint dwVolume);
[DllImport("winmm.dll")]
public static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);
Run Code Online (Sandbox Code Playgroud) 我有一个字符串,它已经给了我的一些愤怒的代码,它有"额外"的字符,我只是偶然发现它使用箭头键来完成它.我注意到光标在某些区域保持原位,以便对箭头键进行额外的击键.使用视图>显示符号>显示所有字符仍然似乎没有表明任何东西.那里有什么样的角色,有插件吗?
使用托管 VS2017 代理成功构建后,我尝试使用本地托管代理部署本地托管代理,该代理是使用域帐户设置的,该帐户应具有足够的权限,因为它在本地管理组中。当我在别处挖掘这个问题时,一位用户使用重新安装了他们的代理NTATHORITY\SYSTEM
并且它起作用了。
我真的不需要创建或停止\启动网站,只需部署最近的构建工件。
我应该检查哪些权限或应该使用其他任务?
019-04-06T21:03:10.3898646Z 错误(消息:配置错误 2019-04-06T21:03:10.3899503Z
2019-04-06T21:03:10.3899791Z 文件名:redirection.config 2019-04-06T21:03:10.3900026Z 2019-04-06T21:03:10.3900293Z 2019-04-04-03Z 行号:1000293Z 行号:0309:03 -04-06T21:03:10.3900852Z 说明:由于权限不足,无法读取配置文件 2019-04-06T21:03:10.3901076Z 2019-04-06T21:03:10.3901333Z。) 2019-04-06T21:03:10.8135484Z ##[错误]进程“appcmd.exe”以代码“5”退出。
Blazor 服务器端,.NET Core 3.1.x 查看有关授权的示例,我正在尝试获取自定义授权过滤器/属性的解决方案。我只需要在授权期间检查用户身份。
https://learn.microsoft.com/en-us/aspnet/core/security/blazor/?view=aspnetcore-3.1
在 Blazor 页面顶部,@page 之后
@attribute [MyAuthFilter]
Run Code Online (Sandbox Code Playgroud)
过滤器。然而,OnAuthorization 永远不会受到影响。
public class MyAuthFilter: AuthorizeAttribute,IAuthorizationFilter
{
public void OnAuthorization(AuthorizationFilterContext context)
{
var httpContext = context.HttpContext;
// get user name
string userName = httpContext.User.Identity.Name;
// todo - call method to check user access
// check against list to see if access permitted
//context.Result = new UnauthorizedResult();
}
}
Run Code Online (Sandbox Code Playgroud) 使用Angular 4.3.0
假设我有一个这样的字符串,它是组件的属性.
<p>test#2 bla bla</p><p>test1234 56</p><p>test test</p>
Run Code Online (Sandbox Code Playgroud)
所以,我跟随文档,https: //angular.io/guide/template-syntax#!#property-binding-or-
interpolation-
这不起作用:
我做错了什么?
<div class="panel-group">
<div class="panel panel-default" *ngFor="let b of BlogPostList">
<div class="panel-heading">{{b.Title}}</div>
<div class="panel-body">
<span style="text-align:left">Created:{{b.DateCreated | date: 'MM/dd/yyyy'}}</span><span style="text-align:right">Last updated{{b.DateUpdated | date: 'MM/dd/yyyy'}}</span>
<br/>
<div [innerHTML]="<b>test here</b>"></div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
错误:
Unhandled Promise rejection: Template parse errors:
Parser Error: Unexpected token < at column 1 in [<b>test here</b>] in ...</span>
<br/>
<div [ERROR ->][innerHTML]="<b>test here</b>"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 我正在运行 .net core 2.2 并在 Windows 服务中托管 asp.net core。
例如。看到这个https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/windows-service?view=aspnetcore-2.2&tabs=visual-studio
我将环境变量 ASPNETCORE_ENVIRONMENT 设置为“Dev”
只是为了确认,在我的 launchsettings.json 中
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT ": "Dev"
}
Run Code Online (Sandbox Code Playgroud)
启动时,HostingEnvironment.EnvironmentName 的值不会更新,仍为默认值“Production”。为什么不是“开发”?
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddEventLog();
})
.ConfigureAppConfiguration((context, config) =>
{
// Configure the app here.
var env = context.HostingEnvironment;
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
})
.UseStartup<Startup>();
Run Code Online (Sandbox Code Playgroud)
}
新手问题,也许这是进行大量客户端开发的结果,但为什么我通常看不到分配了 Id 值的元素?
我没有看到card-block
参考文档中提到的类,但我在一些示例中看到了这个类。这是官方参考:
https://getbootstrap.com/docs/4.0/components/card/
这是使用该类的示例:
https://www.codeply.com/go/pVsGQZVVtG/bootstrap-4-no-gutters-(间距)
我见过用过的卡片,但这个card-block
课程是什么?
例子:
<div class="row">
<div class="col-3">
<div class="card">
<div class="card-block">
normal
</div>
</div>
</div>
<div class="col-4">
<div class="card">
<div class="card-block">
normal
</div>
</div>
</div>
<div class="col">
<div class="card">
<div class="card-block">
normal
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud) c# ×3
.net-core ×2
angular ×2
blazor ×2
.net ×1
asp.net-core ×1
asp.net-mvc ×1
azure-devops ×1
iis ×1
node.js ×1
notepad++ ×1
powershell ×1
windows ×1