随着最近发布的.NET Core 1.0,我们正在将RC1应用程序迁移到最终版本.我们似乎无法弄清楚的唯一一件事是如何集成Active Directory身份验证.
以前在RC1应用程序中,我们使用System.DirectoryServices.AccountManagement库来处理LDAP授权查询.但是,我们不能再将此库与.NET Core v1混合使用.
通常,使用可用于.NET Core框架的库将Active Directory身份验证集成到我们的应用程序中的最佳方法是什么?IdentityServer,其他一些第三方服务,如Auth0或其他什么?
active-directory asp.net-core-mvc .net-core asp.net-core-1.0
是否可以从.NET Core v1.1应用程序中利用System.Data.SqlClient.SqlDependency?似乎System.Data.SqlClient中的大多数其他类和方法都可用,但SqlDependency除外.
本质上,我正在尝试在表数据更改时订阅SQL通知然后更新客户端的UI,因此如果.NET Core中没有SqlDependency,我可以通过其他方式实现此目的.
提前致谢!这是我完整的project.json文件:
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.1.0",
"type": "platform"
},
"Microsoft.AspNetCore.Authentication": "1.0.0",
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"System.IdentityModel.Tokens.Jwt": "5.0.0",
"Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0",
"Microsoft.AspNetCore.Authentication.Google": "1.0.0",
"Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.AspNetCore.StaticFiles": "1.1.0",
"Microsoft.EntityFrameworkCore": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0",
"Microsoft.Extensions.Configuration.Binder": "1.1.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"Microsoft.AspNetCore.Diagnostics": "1.1.0",
"Microsoft.AspNetCore.Identity": "1.1.0",
"Microsoft.AspNetCore.Mvc": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Rewrite": "1.0.0",
"Microsoft.AspNetCore.ResponseCompression": "1.0.0",
"Microsoft.AspNetCore.SignalR.Server": "0.2.0-*",
"Microsoft.AspNetCore.WebSockets": "0.2.0-*"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netstandard1.1": {
"imports": [ …Run Code Online (Sandbox Code Playgroud) 问题:
出于某种原因,启用 CORS 时,Access-Control-Allow-Origin响应中不包含标头。
错误:
从源“https://some.site.com”访问“https://.../api/endpoints/some-path”的 XMLHttpRequest 已被 CORS 政策阻止:对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin”标头。
配置 (.NET MVC 5)
web.config标头:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Credentials" value="true"/>
<add name="Access-Control-Allow-Headers" value="Content-Type" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, OPTIONS" />
</customHeaders>
</httpProtocol>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
Web API 配置:
config.EnableCors();
Run Code Online (Sandbox Code Playgroud)
API 端点:
[RoutePrefix("api/endpoints")]
[EnableCors(origins: "https://some.site.com", headers: "*", methods: "*")]
public class MyApiController : ApiController
{
[HttpPost]
[Route("some-path")]
[EnableCors(origins: "https://some.site.com", headers: "*", methods: "*")]
public ResponseModel GetSomeResponse(DataModel model) { ... }
}
Run Code Online (Sandbox Code Playgroud)
global.asax.cs
protected void Application_BeginRequest(object sender, EventArgs e) …Run Code Online (Sandbox Code Playgroud) 我正在尝试处理要验证的OpenID Connect服务器返回特定的查询字符串集的情况。当条件匹配时,我实际上希望将用户重定向到“访问被拒绝”页面。无论出于何种原因,下面包含重定向的注释行实际上都不会触发。是否有更好/不同的方式来做我要做的事情?
这是在Startup.cs中配置OpenID Connect中间件的方式:
services.Configure<OpenIdConnectOptions>(options =>
{
// ...
options.Events = new OpenIdConnectEvents
{
OnMessageReceived = context =>
{
if (context.HttpContext.Request.Query.ContainsKey("error"))
{
context.HandleResponse(); // <-- Fires
context.Response.Redirect("/AccessDenied"); // <-- Redirect fires but user is not redirected
}
return Task.FromResult(0);
}
}
}
Run Code Online (Sandbox Code Playgroud)
更新:通过以下调整使其工作:
options.Events = new OpenIdConnectEvents
{
OnRemoteFailure = context =>
{
context.HandleResponse();
context.Response.Redirect("AccessDenied?error=" + context.Failure.Message);
return Task.FromResult(0);
},
// ...
};
Run Code Online (Sandbox Code Playgroud) asp.net-core-mvc openid-connect .net-core asp.net-core asp.net-core-1.0
我有一个包含以下属性的类:
public Dictionary<string, int> CommentCounts {
get {
string cacheKey = "CommentCounts";
HttpContext c = HttpContext.Current;
if (c.Cache[cacheKey] == null) {
c.Cache.Insert(cacheKey, new Dictionary<string, int>(), null, DateTime.UtcNow.AddSeconds(30), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.High, null);
c.Trace.Warn("New cached item: " + cacheKey);
}
return (Dictionary<string, int>)c.Cache[cacheKey];
}
set {
HttpContext.Current.Cache["CommentCounts"] = value;
}
}
Run Code Online (Sandbox Code Playgroud)
似乎Trace语句只运行一次,而不是在Cache项目到期后每30秒运行一次.我可以让它刷新缓存项的唯一方法是创建代码机会并重建项目,这显然不太理想.
我错过了什么?提前致谢...
这是我试图在纯CSS中创建的形状:
我有一个更完整的jsfiddle http://jsfiddle.net/8Lxr5s57/7/.是否有更好,更有效的方法来实现同样的结果?
.angled_container {
background-color: #fff;
height: 200px;
position: relative;
overflow: hidden;
clear: both;
}
.angled_container:before,
.angled_container:after {
content: "";
width: 110%;
height: 100%;
display: block;
position: absolute;
top: 0;
}
.angled_container:before {
background-color: #606060;
transform: rotate(12deg);
-webkit-transform-origin: left top;
left: 0;
}
.angled_container:after {
background-color: #6bb2c6;
transform: rotate(-12deg);
-webkit-transform-origin: right top;
left: -10%;
}
.angled_container--open-left:before {
background-color: #6bb2c6;
z-index: 2;
}
.angled_container--open-left:after {
background-color: #606060;
z-index: 1;
}Run Code Online (Sandbox Code Playgroud)
<div class="angled_container angled_container--open-right"></div>Run Code Online (Sandbox Code Playgroud)
我似乎无法正确地将以下内容从VB.NET转换为C# -
iKeyChar = Asc(mid(g_Key, i, 1))
iStringChar = Asc(mid(strCryptThis,i,1))
Run Code Online (Sandbox Code Playgroud)
这是我转换的C#代码,它似乎没有输出等价值 -
iKeyChar = Convert.ToInt32(g_Key.Substring(i, 1));
iStringChar = Convert.ToInt32(strCryptThis.Substring(i, 1));
Run Code Online (Sandbox Code Playgroud)
任何帮助是极大的赞赏!
.net-core ×3
c# ×3
asp.net-core ×2
api ×1
asp.net ×1
asp.net-mvc ×1
caching ×1
css ×1
css-shapes ×1
css3 ×1
svg ×1
vb.net ×1