我正在开发Angular2(Beta 8)中的一个组件.该组件有一个文本框和一个下拉列表.我想在加载组件时或在下拉列表的更改事件中将焦点设置在文本框中.我如何在angular2中实现这一目标.以下是组件的Html.
<div>
<form role="form" class="form-horizontal ">
<div [ngClass]="{showElement:IsEditMode, hidden:!IsEditMode}">
<div class="form-group">
<label class="control-label col-md-1 col-sm-1" for="name">Name</label>
<div class="col-md-7 col-sm-7">
<input id="name" type="text" [(ngModel)]="person.Name" class="form-control" />
</div>
<div class="col-md-2 col-sm-2">
<input type="button" value="Add" (click)="AddPerson()" class="btn btn-primary" />
</div>
</div>
</div>
<div [ngClass]="{showElement:!IsEditMode, hidden:IsEditMode}">
<div class="form-group">
<label class="control-label col-md-1 col-sm-1" for="name">Person</label>
<div class="col-md-7 col-sm-7">
<select [(ngModel)]="SelectedPerson.Id" (change)="PersonSelected($event.target.value)" class="form-control">
<option *ngFor="#item of PeopleList" value="{{item.Id}}">{{item.Name}}</option>
</select>
</div>
</div>
</div>
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
我遇到ASP.NET Core没有正确提供静态文件的问题.我在www-根目录下的node_modules中有我的部分应用程序.在大多数情况下,所有文件都有效,但也有例外.*.js.map文件被路由到MVC控制器,为我的MVC页面而不是实际文件提供服务.结果,我在浏览器中收到错误,例如
无法解析SourceMap:http:// localhost:5000/node_modules/bootstrap/bootstrap.min.css.map
走同样的路线,我的网络字体,例如包含Bootstrap的网络字体也没有正确提供,也由MVC中间件而不是静态文件中间件处理.似乎所有驻留在node_modules中的文件都应该路由到我的静态文件中间件,而这种情况并没有发生.谢谢.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(Path.Combine(env.WebRootPath, @"node_modules")), RequestPath = new PathString("/node_modules"), ServeUnknownFileTypes = true }); app.UseMvc(config => { config.MapRoute("Default", "{controller}/{action}/{id?}", new { controller = "Home", action = "Index" }); config.MapRoute("AngularDeepLinkingRoute", "{*url}", new { controller = "Home", action = "Index" }); }); }
我正在尝试下载 libcheck。但 Microsoft.com 上的链接已损坏,也无法在 Microsoft.com 上搜索
这个工具已经停产了吗?如果是的话,微软还有其他工具可以替代这个工具吗?
在使用EFCore加密SQLite数据库时,我遇到了这个GitHub问题
请参阅8月1日bricelam的评论.此问题解释了如何使用efcore加密SQLite数据库.它指的是Microsoft.EntityFrameworkCore.Sqlite.Core.然而,还有另一个软件包"Microsoft.EntityFrameworkCore.Sqlite",它在许多微软文档中被广泛使用和引用.我想知道这两个组件之间的区别,我应该使用哪个组件?
如果我使用Microsoft.EntityFrameworkCore.Sqlite.Core,我会错过任何功能吗?
我有一个使用完整的.net 框架(.Net 4.6.1)在asp.net core 中开发的应用程序。该应用程序是使用 Visual Studio 2017 RC 创建的。编译成功后,生成了TestApplication.exe。
\n\n当我转到项目根目录并执行命令 dotnet run 时,应用程序将启动并开始侦听端口 5000。使用此方法应用程序运行良好。但是,当我转到projectRoot\\ bin\\Debug\\net461\\
并启动 TestApplicatin.exe 时,它也开始侦听端口 5000,但是当我转到浏览器并输入http://localhost:5000时,出现以下错误
\n\n\n本地主机页面\xe2\x80\x99t 正在工作
\n
localhost 当前无法处理此请求。
\n\nHTTP 错误 500
\n\n笔记-
\n\n请查看Program.cs文件的内容
\n\npublic static void Main(string[] args)\n {\n var host = new WebHostBuilder()\n .UseKestrel()\n .UseContentRoot(Directory.GetCurrentDirectory())\n .UseIISIntegration()\n .UseStartup<Startup>()\n .Build();\n\n host.Run();\n }\n
Run Code Online (Sandbox Code Playgroud)\n 我在 ASP .NET Core 2.1 应用程序中注销(注销)时收到以下错误
没有为“联合”方案注册注销身份验证处理程序。注册的注销方案有:WsFederation、Cookies。您是否忘记调用 AddAuthentication().AddCookies("Federation",...)
这是我的 Startup.cs 中的代码片段
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(sharedOptions =>
{
sharedOptions.DefaultScheme =
CookieAuthenticationDefaults.AuthenticationScheme;
sharedOptions.DefaultSignInScheme =
CookieAuthenticationDefaults.AuthenticationScheme;
sharedOptions.DefaultChallengeScheme =
WsFederationDefaults.AuthenticationScheme;
})
.AddWsFederation(options =>
{
options.Wtrealm = this._wtrealm;
options.MetadataAddress = this._metadataAddress;
})
.AddCookie();
}
Run Code Online (Sandbox Code Playgroud)
这是 SignOut 方法的代码
public IActionResult SignOut()
{
foreach (var key in this.HttpContext.Request.Cookies.Keys)
{
this.HttpContext.Response.Cookies.Delete(key);
// this.HttpContext.Response.Cookies.Append(key,
// string.Empty,
// new CookieOptions() {
// Expires = DateTime.Now.AddDays(-1)
// });
}
return this.SignOut(
new Microsoft.AspNetCore.Authentication.AuthenticationProperties
{
RedirectUri = this.GetReturnUrl()
},
CookieAuthenticationDefaults.AuthenticationScheme, …
Run Code Online (Sandbox Code Playgroud) 我有一个包含几个泰语字符的字符串。此字符串使用 unicode 字符。但是我在 IDE 中看不到泰语字符,即使我在文本文件中写了字符串。如果我想正确地看到泰文字符,我必须编写以下代码
var text = "M_M-150 150CC. เดี่ยว (2 For 18 Save 2)";
var ascii = Encoding.Default.GetBytes(text);
text = Encoding.UTF8.GetString(ascii);
Run Code Online (Sandbox Code Playgroud)
应用上述逻辑后,我可以正确地看到带有泰语字符的字符串。这是输出
// notice the thai character ?????? in the string
M_M-150 150CC. ?????? (2 For 18 Save 2)
我不确定为什么我需要应用上述逻辑来查看泰语字符,即使字符串是 Unicode?在这种情况下,Encoding.Default 到底在做什么?