在启动类中,我将以下行添加到我的 asp.net 核心应用程序中
services.AddResponseCompression();
Run Code Online (Sandbox Code Playgroud)
所以 configureServices 方法如下所示
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<MyDBContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddCors(options =>
{
options.AddPolicy("AllowAll",
builder =>
{
builder
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});
services.AddMvc();
services.AddResponseCompression();
}
Run Code Online (Sandbox Code Playgroud)
我还添加了以下行来配置方法
app.UseResponseCompression();
Run Code Online (Sandbox Code Playgroud)
这是配置方法
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseCors("AllowAll");
app.UseResponseCompression();
app.UseMvc();
}
Run Code Online (Sandbox Code Playgroud)
现在,当我运行该项目时,它运行得更快,响应的大小已经减小和压缩(我通过 chrome 控制台网络选项卡检查了它),响应压缩中间件的目的是压缩响应
我的问题是:使用这个中间件有什么缺点吗,或者有什么情况我不应该使用响应压缩?
我创建了一个类型为 Typescript 和 html application 的新 Visual Studio 项目,我正在尝试创建一个 shadow dom,但出现错误。
class Append{
element: HTMLElement;
constructor(element: HTMLElement) {
this.element = element;
}
window.onload = () => {
var el = document.getElementById('content');
let shadow = el.attachShadow({mode: 'open'});
}
Run Code Online (Sandbox Code Playgroud)
类型元素上不存在属性 attachshadow
在发布这个问题之前,我认为这是一个简单的问题,我搜索答案并没有找到合适的解决方案.
在我的日常工作中,我正在使用Web应用程序,可以轻松获取或设置下拉列表的值
我不能在Windows应用程序C#中做同样的事情
我有组合框和类comboItem
public class ComboItem
{
public int Key { get; set; }
public string Value { get; set; }
public ComboItem(int key, string value)
{
Key = key; Value = value;
}
public override string ToString()
{
return Value;
}
}
Run Code Online (Sandbox Code Playgroud)
假设组合框通过硬编码绑定,值为
关键:2 /价值:女性
关键:3 /价值:未知
假设我有Key = 3并且我想通过代码设置此项(其键为3),因此在加载表单时,默认情况下所选的值将为Unknown.
combobox1.selectedValue =3 //Not Working , selectedValue used to return an object
combobox1.selectedIndex = 2 //Working as 2 is the index of key 3/Unknown
Run Code Online (Sandbox Code Playgroud)
但是让我说我不知道索引,我怎样才能得到key = 3的项目的索引? …