小编Blu*_*ght的帖子

未设置 ASP.NET Core 2.0 身份验证 Cookie

我按照Microsoft 的这篇文章 ( https://docs.microsoft.com/en-us/aspnet/core/security/authentication/cookie?tabs=aspnetcore2x ) 在我的 .NET Core 2.0 MVC 应用程序中迁移了我的身份验证程序。

Startup.cs(配置服务)

services.AddIdentity<ApplicationUser, IdentityRole>()
            .AddEntityFrameworkStores<ApplicationDbContext>()
            .AddDefaultTokenProviders();

services.AddAuthentication("MyCookieAuthenticationScheme")
        .AddCookie("MyCookieAuthenticationScheme", options => {
            options.AccessDeniedPath = "/Account/Forbidden/";
            options.LoginPath = "/Account/Login/";
        });
Run Code Online (Sandbox Code Playgroud)

Startup.cs(配置)

app.UseAuthentication();
Run Code Online (Sandbox Code Playgroud)

账户控制器.cs

List<Claim> claims = new List<Claim> {
                        new Claim(ClaimTypes.Name, "testUser"),
                        new Claim(ClaimTypes.Email, model.Email),
                        //new Claim("ID", user.ID.ToString(), ClaimValueTypes.Integer),
                        new Claim(ClaimTypes.Role, "Admin")
                    };

ClaimsIdentity identity = new ClaimsIdentity(claims, "MyCookieAuthenticationScheme");

ClaimsPrincipal principal = new ClaimsPrincipal(identity);

await HttpContext.SignInAsync("MyCookieAuthenticationScheme", principal, new AuthenticationProperties
{
    IsPersistent = false
});
Run Code Online (Sandbox Code Playgroud)

不幸的是,我的 .NET Cookie 从未设置过。这意味着 User.Identity.IsAuthenticated 始终为 false。我尝试了许多 cookie …

c# cookies asp.net-mvc asp.net-core asp.net-core-2.0

6
推荐指数
1
解决办法
8047
查看次数

VS 2017 中本地主机上的 .NET Core MVC 项目的 Javascript 性能缓慢

介绍:

我正在开发一款基于.NET Core MVC 的策略游戏。游戏的主要部分是用 JavaScript 编写的,因此在客户端执行。

计算最密集的部分是在画布上不断重绘“游戏地图”,尤其是当您在地图中导航时。每次击键(W、A、S、D)时,它必须检查数组中的许多对象(建筑物、瓷砖等)。

代码中的小摘录,这样你就明白了:

render();
requestAnimFrame(main);

function render() {
    renderMapBuildings() 
}

function renderMapBuildings(list) {
    //var count = 0;
    for(var i=0; i<list.length; i++) {
        if ((list[i].pos[1] + camera.pos[1]) < CANVAS_HEIGHT && (list[i].pos[0] + camera.pos[0]) < CANVAS_WIDTH && (list[i].pos[1] + camera.pos[1]) > -60 && (list[i].pos[0] + camera.pos[0]) > -60) {               
            if (list[i].id == Building.Current.id && list[i].type == 1)
                ctx.shadowBlur = 20;
            //count++;
            renderEntity(list[i]);  
            ctx.shadowBlur = 0;
        }
    }
    //console.log("mapbuildings_new length: " + count);
}

function renderEntity(entity) { …
Run Code Online (Sandbox Code Playgroud)

javascript localhost iis-express asp.net-core visual-studio-2017

5
推荐指数
0
解决办法
495
查看次数

三.JS:基于不同的tilesets渲染大地图(Texture Atlas)

介绍:

我用 Three.JS (v95, WebGL Renderer) 渲染了等距图。该地图包括许多不同的图形图块集。我通过 TextureAtlasLoader 获取特定的 tile,它的位置来自 JSON。它看起来像这样:

查看地图

问题是我渲染的图块越多它的执行速度就越慢(我需要在一张地图上渲染大约 120,000 个图块)。那时我几乎不能移动相机。我知道有几种比将每个图块作为精灵添加到场景中更好的方法。但我不知何故被卡住了。

从用于创建图块的代码中提取的当前内容(在循环中):

var ts_tile = Map.Imagesets[ims].Map.getTexture((bg_left / tw), (bg_top / th));
var material = new THREE.SpriteMaterial({ map: ts_tile, color: 0xffffff, fog: false });
var sprite = new THREE.Sprite(material);
sprite.position.set(pos_left, -top, 0);
sprite.scale.set(tw, th, 1);

scene.add(sprite)
Run Code Online (Sandbox Code Playgroud)

我也尝试将其渲染为 Mesh,它也可以工作,但性能是相同的(当然):

var material = new THREE.MeshBasicMaterial({ map: ts_tile, color: 0xffffff, transparent: true, depthWrite: false });
var geo = new THREE.PlaneGeometry(1, 1, 1);
var sprite = new THREE.Mesh(new THREE.BufferGeometry().fromGeometry(geo), material);
Run Code Online (Sandbox Code Playgroud)

网络上可能的解决方案:

我知道我不能在一个场景中添加这么多精灵或网格,我尝试了不同的东西并查看了示例,它可以完美地工作,但我无法将他们的方法调整到我的代码中。我地图上的每个图块都有不同的纹理,并且有自己的位置。 …

javascript performance three.js

5
推荐指数
1
解决办法
2268
查看次数