使用SslStream和socket,我从头开始开发了一个https Web服务器.我可以将证书应用于来自C#代码的流并处理请求.
但是,我并没有弄清楚如何用Owin做到这一点.有没有人知道如何将证书绑定到自托管控制台应用程序?
例:
// Bind the below certificate to Owin host
var certificate = new X509Certificate2("server.pfx", "password");
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅下面的现有Owin主机代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Owin.Hosting;
using AppFunc = System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>;
namespace Owin.Startup
{
class Program
{
static void Main(string[] args)
{
int port = 8888;
string url = $"http://localhost:{port}";
using (WebApp.Start<Startup>(url))
{
Console.WriteLine($"Hosted: {url}");
Console.ReadLine();
}
}
}
public class Startup
{
private IAppBuilder app;
public void Configuration(IAppBuilder app)
{
#if DEBUG
app.UseErrorPage(); …Run Code Online (Sandbox Code Playgroud) AngularJS允许您实现双向数据绑定.然而,有趣的部分是它如何检测模型变化?该模型通常是一个普通的对象,如下面的代码.我们可以更改名称属性,$scope.user但AngularJS如何检测模型已更改?AngularJS是否枚举了$scope对象的所有属性?
angular.module('myApp', [])
.controller('BusinessCardController', function($scope){
$scope.user = {
name: 'Tanay Pant'
}
});
<input type="text" ng-model="user.name" placeholder="Full Name" />
Run Code Online (Sandbox Code Playgroud) 请参阅下面的模板,如何添加条件,以确保menu不是undefined里面v-for的属性?
我试过了v-for="menu?item in menu.items:[]",v-for="item in menu?.items"但都没有用.
<div v-for="item in menu.items">{{item.text}}</div>
Run Code Online (Sandbox Code Playgroud) 请参阅下面的代码,即使指定了插槽名称,当前所有子项都在默认插槽中呈现。
不确定 vue createElement 函数是否支持命名槽?
@Component({
props:[]
})
export class TestComponent extends Widget{
items:any[];
render(h:any){
const rootcmp = {
template:`<div>
Temp:<slot name="temp"></slot>
Default:<slot></slot>
</div>`
, data:()=>{
return {};
}
}
const cmp = {
template:'<div slot="default">This is child</div>'
, data:()=>{
return {};
}
}
const cmp2 = {
template:'<div slot="temp">This is child</div>'
, data:()=>{
return {};
}
}
return h(rootcmp, [h(cmp), h(cmp2)]);
}
}
Run Code Online (Sandbox Code Playgroud)
当前行为:
<div>
Temp:Default:
<div>This is child</div>
<div>This is child</div>
</div>
Run Code Online (Sandbox Code Playgroud)
预期行为:
<div>
Temp:
<div>This is child</div> …Run Code Online (Sandbox Code Playgroud) 我有一个需要SOS.dll 4.0.30319.1008的迷你转储,但是winDBG无法下载正确的dll.符号路径已设置为SRV*C:\symcache*http://msdl.microsoft.com/download/symbols
有没有人知道在哪里下载SOS.dll提供版本号?我决定手动下载DLL并将其替换为Windows下的Microsoft.net折叠.
在为自主主机Owin控制台应用程序设置HTTP时出现问题.浏览器始终显示连接重置错误.
我已尝试根据此链接http://chavli.com/how-to-configure-owin-self-hosted-website-with-ssl/手动创建证书,但我仍然在该端口上遇到连接重置问题.我已经检查了Windows事件日志,并且没有错误消息.
应用程序将自行创建X509证书并自动运行netsh命令.
没有Ssl,应用程序可以正确显示网页.
任何人都可以在下面运行我的代码并查看它是否可以在您的计算机上运行?提前致谢.
需要添加COM引用CertEnroll 1.0 Type Library来编译下面的代码(vs2015已在类型库中包含此COM引用)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using CERTENROLLLib;
using Microsoft.Owin.Hosting;
using AppFunc = System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>;
namespace Owin.Startup
{
class Program
{
static void Main(string[] args)
{
int port = 8888;
string url = $"https://localhost:{port}";
var cert = GetCert("localhost", TimeSpan.FromDays(3650), "devpwd", AppDomain.CurrentDomain.BaseDirectory + "cert.dat");
ActivateCert(cert, port, GetAppId());
using (WebApp.Start<Startup>(url))
{
Console.WriteLine($"Hosted: {url}");
Console.ReadLine(); …Run Code Online (Sandbox Code Playgroud) 要在 vscode 中为 jasmine 等框架启用智能感知,我们需要在每个打字稿文件的顶部显式引用打字文件,如下所示:
/// <reference path="./node_modules/@types/jasmine/index.d.ts" />
Run Code Online (Sandbox Code Playgroud)
有没有办法全局引用 vscode 中的所有打字文件,这样我们就不需要在每个打字稿文件中引用它们?
intellisense reference typescript visual-studio-code typescript-typings
StringBuilder是否比连接十几个字符串慢?编译器如何优化字符串连接,以便使用"+"连接十几个字符串将比StringBuilder更好?
从一本书(Ben Watson编写)中可以看出:
字符串连接:对于已知(在编译时)数量的字符串的简单连接,只需使用'+'运算符或String.Concat方法.这通常比使用StringBuilder更有效.string result = a + b + c + d + e + f; 在字符串数量可变且可能大于几十个之前,不要考虑StringBuilder.编译器将以减少内存开销的方式优化简单字符串连接.
参考下面的链接,我们可以使用以TypeScript编写的基于类的vue组件。
使用这些自定义组件的正确方法是什么?
例如,下面的Es5代码定义了一个可以在其他组件模板中使用的组件,例如,<my-component></my-component>因为我们将名称'my-component'作为Vue.component方法的参数。 如何在打字稿中实现这一点?
Vue.component('my-component', {
template: '<span>{{ message }}</span>',
data: {
message: 'hello'
}
})
Vue.component('parent-component', {
template: '<my-component></my-component>'
})
Run Code Online (Sandbox Code Playgroud)
https://vuejs.org/v2/guide/typescript.html#Class-Style-Vue-Components https://alligator.io/vuejs/typescript-class-components/
基于类的Vue组件 可以在其他组件的模板字符串中使用的该组件的标记名是什么?
import Vue from 'vue'
import Component from 'vue-class-component'
// The @Component decorator indicates the class is a Vue component
@Component({
// All component options are allowed in here
template: '<button @click="onClick">Click!</button>'
})
export default class MyComponent extends Vue {
// Initial data can be declared as instance properties
message: …Run Code Online (Sandbox Code Playgroud)