我可以通过Debug - > Windows - > Show Diagnostic Tool显示诊断工具窗口.
但是,在启动/调试应用程序时,窗口总是会消失.
到底是怎么回事?
我正在尝试使用"Microsoft.AspNetCore.ResponseCaching"包在我的web api中实现响应缓存.
我正在使用Postman测试应用程序并验证标题等.
使用指定的max-age生成正确的标头,但邮递员似乎从api请求响应而不使用缓存.响应时间根本没有变化,如果我调试控制器,我可以看到它每次都被请求命中.
启动类ConfigureServices(以及其他内容):
services.AddResponseCaching();
Run Code Online (Sandbox Code Playgroud)
启动类配置(以及其他内容):
app.UseResponseCaching();
app.UseMvc();
Run Code Online (Sandbox Code Playgroud)
控制器动作:
[HttpGet("{employeeNr}", Name = EmployeeAction)]
[ResponseCache(Duration = 50)]
[Produces(typeof(EmployeeDto))]
public async Task<IActionResult> GetEmployee(SpecificEmployeeParameters parameters)
{
if (!await _employeeRepository.EmployeeExists(parameters.EmployeeNr)) return NotFound();
if (!_typeHelperService.TypeHasProperties<EmployeeDto>(parameters.Fields))
return BadRequest();
var entity = await _employeeRepository.GetEmployee(parameters.EmployeeNr);
var result = Mapper.Map<EmployeeDto>(entity);
return Ok(result.ShapeData(parameters.Fields));
}
Run Code Online (Sandbox Code Playgroud)
邮递员的回复标题:
cache-control ?private,max-age=50
content-type ?application/json; charset=utf-8
date ?Wed, 30 Aug 2017 11:53:06 GMT
Run Code Online (Sandbox Code Playgroud) 我有一段时间遇到问题了,只是找不到任何适合我的解决方案。我有一个ListBox里面装满了DataTable类似的东西
listbox.DataSource = table;
listbox.Displaymember = "Name";
listbox.ValueMember = "ID";
Run Code Online (Sandbox Code Playgroud)
如果我现在在列表框中选择一个项目,我可以将其取出,如下所示:
listbox.SelectedValue.toString();
Run Code Online (Sandbox Code Playgroud)
我的问题:
如果我想从ListBox启用了多重选择的地方获取所有选定的值并将它们全部保存在数组或类似的东西中,我该怎么办?
我无法使用,SelectedItems因为它没有给我提供我需要的信息。
我正在考虑验证用户输入的最佳方法.
让我们设想一些TextBoxes,CheckBoxes或任何你喜欢的.NET控件,其中用户输入必须被验证为OK或NOK.一旦用户填写了他通过按钮提交的所有必填字段.
现在我必须知道哪些字段先前已确认为OK,哪些字段为NOK.到目前为止,我总是通过为每个控件声明一个全局bool变量来处理这种情况.但我不喜欢那样......
我很确定必须有另一种方式!我想要做的是使用名为status或类似的OK或NOK属性扩展这些.NET控件.你能做到吗?如果是这样,你怎么做?这样的东西已经存在吗?
感谢您的答复!
这是我第一次使用LINQ而我还没有真正得到它.
我试图通过一个例子来理解它,但我需要一些帮助.
我创建了一个类"Person":
class Person
{
private string name { get; set; }
private int age { get; set; }
private bool parent { get; set; }
private bool child { get; set; }
public Person(string name, int age, bool parent, bool child)
{
this.name = name;
this.age = age;
this.parent = parent;
this.child = child;
}
}
Run Code Online (Sandbox Code Playgroud)
我创建了一个"人物"列表:
people.Add(new Person("Joel", 12, false, true));
people.Add(new Person("jana", 22, false, false));
people.Add(new Person("Stefan", 45, true, false));
people.Add(new Person("Kurt", 25, false, false));
people.Add(new …Run Code Online (Sandbox Code Playgroud) 由于this.name无法访问具有相同名称的字段(如静态类中的方法参数),我正在寻找一种方法.
作为一个例子,我想这样做:
static class test
{
private static string aString;
public static void method(string aString)
{
// aString (field) = aString (parameter)
}
}
Run Code Online (Sandbox Code Playgroud) 我想使用DateTime对象中的ParseExact方法,就像我之前做过很多次一样......(这是我第一次在ASP.NET中使用C#)
但ParseExact方法不存在......
我想做这样的事情:
DateTime dt = DateTime.ParseExact(Date, "dd.mm.yyyy", provider);
Run Code Online (Sandbox Code Playgroud)
但我得到的唯一选择是:
DateTime.Equals
DateTime.ReferenceEyuals
DateTime.CreateHtmlTextWritersFromType
Run Code Online (Sandbox Code Playgroud)
我只是不明白为什么?