我对Windows和Mac OS机器上的ASP.NET 5很感兴趣.首先,我在Windows机器上安装了Visual Studio 2015 RC.我为ASP.NET 5(又名vNext)创建了一个新的空网站.我使用Views目录更新了模板,并包含了MVC和Static Files nuget包.我可以成功运行这个"Hello World"应用程序.我也成功地将其检入GitHub并自动将其部署到Azure作为网站.
然后,我在Mac OS机器上克隆了存储库.我成功跑去dnu restore拿包裹.然后我跑了dnx . run.当我这样做时,我收到了一个错误.错误是:
'Website' does not contain a static 'Main' method suitable for an entry point
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?我有一个Startup.cs文件.我知道它的工作原理是它在Windows和Azure上运行.然而,我无法弄清楚我错过了什么.我的Startup.cs文件如下所示:
Startup.cs
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.Framework.ConfigurationModel;
using Microsoft.Framework.DependencyInjection;
namespace Test.Site.Web
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
public void Configure(IApplicationBuilder app)
{
app.UseErrorPage();
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute("default",
"{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index" });
});
app.UseMvc(); …Run Code Online (Sandbox Code Playgroud) 我一直在使用Jasmine的Webdriver I/O进行端到端测试.一个特定的场景给了我很大的挑战.
我有一个页面,上面有5个链接.由于页面是动态的,链接的数量实际上是挑战.我想测试链接,看看每个链接是否title与title它链接到的页面相匹配.由于链接是动态生成的,我不能只为每个链接进行硬编码测试.所以,我正在尝试以下方法:
it('should match link titles to page titles', function(done) {
client = webdriverio.remote(settings.capabilities).init()
.url('http://www.example.com')
.elements('a').then(function(links) {
var mappings = [];
// For every link store the link title and corresponding page title
var results = [];
for (var i=0; i<links.value.length; i++) {
mappings.push({ linkTitle: links.value[0].title, pageTitle: '' });
results.push(client.click(links.value[i])
.getTitle().then(function(title, i) {
mappings[i].pageTitle = title;
});
);
}
// Once all promises have resolved, compared each link title to each corresponding page title
Promise.all(results).then(function() …Run Code Online (Sandbox Code Playgroud) 我有一个模拟向导的网页.在用户离开第二步以进入第三步之后,我就像卡片一样"翻转"面板.你可以在这个Bootply中看到它的运行情况.代码如下所示:
<div class="container-fluid" style="background-color:#eee;">
<div class="container">
<div class="flip-container" style="width:200px;">
<div class="flipper">
<div class="front">
<div class="step-2-default" id="step2" style="overflow-x:hidden; padding:0.0rem 1.0rem;">
<label>Step 2</label>
<p>These are the details of the second step</p>
<button id="nextButton2">next</button>
</div>
<div class="step-1-default" id="step1">
<label>Step 1</label>
<p>These are the details of the first step</p>
<button id="nextButton1">next</button>
</div>
</div>
<div class="back">
<div id="step3">
<label>Step 3</label>
<p>Thank you for using this wizard</p>
</div>
</div>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
如果您加载Bootply,您会注意到从步骤1和2可以看到该步骤.根据我的理解,问题是height:auto属性.我正在使用它,因为我的向导中每个步骤的内容大小都是动态的.
它在Chrome中运行良好.但是,我无法弄清楚如何让它在iOS/Safari中运行.任何帮助表示赞赏.
我正在使用Node.js编写应用程序。具体来说,我正在使用Node v10.3.0。该应用程序位于的目录中./my-module-console/index.js。这个应用程式的的package.json档案位于./my-module-console/package.json。此应用程序引用了中定义的类./my-module/items/。应该注意的是,它my-module代表了自己的包装。该软件包在中定义./my-module/package.json。index.js中的代码如下所示:
'use strict';
import { Item } from '../my-module/items/item.js';
async function entry() {
let item = await Item.FindById(1);
console.log(item);
}
entry();
Run Code Online (Sandbox Code Playgroud)
当我尝试运行此命令时,出现以下错误:
import { Item } from '../my-module/items/item.js';
^
SyntaxError: Unexpected token {
Run Code Online (Sandbox Code Playgroud)
我的进口货单有什么问题?在我看来,这是正确的。我误会了吗?
item.js
class Item {
constructor() {}
async static FindById(id) {
console.log('finding item by id: ' + id);
}
};
module.exports = Item;
Run Code Online (Sandbox Code Playgroud)
谢谢!
我有一个C#应用程序,它使用自定义部分进行配置.我将XML的那一部分定义为字符串.字符串看起来像这样:
var xml = @"<departments>
<department id=""1"" name=""Sporting Goods"">
<products>
<product name=""Basketball"" price=""9.99"">
<add key=""Color"" value=""Orange"" />
<add key=""Brand"" value=""[BrandName]"" />
</product>
</products>
</department>
</departments>";
Run Code Online (Sandbox Code Playgroud)
此XML与我在此处描述的类定义的模式匹配.当我将上面的字符串传递给Departments.Deserialize方法时,我收到一个错误.错误说:"无法识别的元素'添加'".调试器跳到我Departments班上的这一行.
public void ReadXml(XmlReader reader)
{
this.DeserializeElement(reader, false);
}
Run Code Online (Sandbox Code Playgroud)
我假设错误是指'product'元素中的'add'元素.但是,Product ConfigurationElement有一个名为的属性KeyValueConfigurationCollection Items.出于这个原因,似乎add可行.
为什么我收到此错误如何修复我的代码,以便可以反序列化上面显示的XML字符串?
我的计算机上正在运行一个Electron应用程序(Slack)。我想运行一些读取该应用程序HTML DOM的JavaScript。这可能吗?如果是这样,某处是否有“入门”?
在我看来,由于Electron使用Node.js托管HTML / JavaScript,所以我可能可以读取DOM。同时,我看到不允许这样做,因为这可能会带来安全风险。我可以接受安全风险,因为它正在我的计算机上运行。因此,我假设会有UAC提示。不过,我只是试图找出如何从外部脚本中读取DOM的方法。
谢谢
我正在将控制台应用程序从 .NET Legacy 迁移到 .NET Core 2.2。在那个应用程序中,我使用HttpClient和HttpRequestMessage类。有时,使用这些类发出的请求会失败。出于这个原因,我system.diagnostics在 App.config 文件中有一个块来记录诊断问题的原始请求。虽然这在我的旧应用程序中有效,但我现在在 .NET Core 中遇到错误。
当我启动我的应用程序时,我看到以下错误:
ConfigurationErrorsException: Unrecognized configuration section system.diagnostics.
Run Code Online (Sandbox Code Playgroud)
我添加到 App.config 文件中的唯一内容是: <system.diagnostics></system.diagnostics>,这是一个空的配置块。如果我删除该块,我的应用程序会按预期运行。
如何将system.diagnostics旧应用中使用的配置添加到我的 .NET Core 应用中,以便我可以再次跟踪原始 Web 请求?
谢谢!
我在我的应用程序中使用Bootstrap DatePicker控件。我试图弄清楚如何清除该字段的值。问这个问题我有点傻。老实说,它看起来应该很简单。但是,我一直没有成功。我已经尝试过在本SO帖子中推荐的方法,但是没有运气。
目前,我有这个JSFiddle。我的问题代码如下所示:
$(function() {
$('#birthday').datetimepicker({ showTodayButton: true });
$('#getDateButton').on('click', function() {
var selectedDate = $('#birthday').data('date');
if (selectedDate) {
selectedDate = selectedDate.format('MM-DD-YYYY');
}
$('#formattedDate').html(selectedDate);
});
$('#clearButton').on('click', function() {
alert('Clear the value in the "birthday" field...');
$('#birthday').data('clear');
// what now?
});
});
Run Code Online (Sandbox Code Playgroud)
就像控件中的功能不起作用一样。或者,文档不正确。如小提琴所示,我的“获取日期”功能也不起作用。这就是为什么我觉得有些不对劲。我错过了什么还是误会了?
我有一个使用 .NET 4.7 构建的解决方案。该解决方案有两个项目:
我正在尝试迁移此解决方案以使用 .NET Standard | 核。
我已成功将类库转移到 .NET Standard 2.0 项目。我还将单元测试项目转移到.NET Core 2.0 mstest 项目。一切都编译。我可以按预期运行我的测试。但是,没有日志通过 NLog 写入。
在我的 .NET 4.7 版本的解决方案中,当我运行单元测试时,实际的日志文件是通过 NLog 写入的。但是,在新的 .NET Standard | 核心实现,这个日志文件没有被写入。我的 mstest 项目中有以下两个文件:
应用配置
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
</configuration>
Run Code Online (Sandbox Code Playgroud)
配置文件
<?xml version="1.0" encoding="utf-8" ?>
<!-- XSD manual extracted from package NLog.Schema: https://www.nuget.org/packages/NLog.Schema-->
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xsi:schemaLocation="NLog NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogFile="c:\temp\console-example-internal.log"
internalLogLevel="Info" >
<targets>
<target name="myLogs" xsi:type="File" deleteOldFileOnStartup="true" fileName="${basedir}/logs/MyLogs.json" createDirs="true" keepFileOpen="true" encoding="utf-8" layout="${message}" /> …Run Code Online (Sandbox Code Playgroud) 我有一个Node.js应用。当我从命令行运行时node -v,会看到以下内容:
v10.3.0
这很重要,因为我对使用Performance Hooks感兴趣。我创建了我能想到的最基本的东西,它看起来像在一个名为“ index.js”的文件中:
const performance = require('perf_hooks');
let p = performance.now();
Run Code Online (Sandbox Code Playgroud)
从命令行运行时node index.js,出现错误消息:
TypeError:performance.now不是函数
为什么会出现此错误?我想念什么?