小编Pus*_*ots的帖子

虚拟关键字,包括扩展方法,延迟加载,急切加载 - 加载相关对象如何实际工作

在MVC中加载相关对象可能非常混乱.

如果您真的想知道在编写实体模型类和控制器时您正在做什么,那么您需要了解并学习很多术语.

我在很长一段时间内遇到的几个问题是:virtual关键字如何工作以及何时应该使用它?Include扩展方法如何工作以及何时使用它?

这就是我所说的;

virtual 关键词:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace LazyLoading.Models
{
    public class Brand
    {
        public int BrandId { get; set; }
        public string Name { get; set; }
        public int ManufacturerId { get; set; }
        public virtual Manufacturer Manufacturer { get; set; }
    }
}
Run Code Online (Sandbox Code Playgroud)

Include扩展方法:

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LazyLoading.Models;

namespace LazyLoading.Controllers
{
    public class …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc entity-framework lazy-loading eager-loading

6
推荐指数
2
解决办法
5853
查看次数

有人可以向我解释什么时候我会在 Kubernetes 中使用“App Root”注释

我已经阅读文档一千次,但我仍然不明白我将如何使用nginx.ingress.kubernetes.io/app-root注释。

有人可以用简单的英语提供示例+描述吗?

文档:https : //kubernetes.github.io/ingress-nginx/examples/rewrite/

我不妨复制粘贴整个文本;没那么多。

nginx.ingress.kubernetes.io/app-root    Defines the Application Root that the Controller must redirect if it's in '/' context   string
Run Code Online (Sandbox Code Playgroud)

应用程序根

创建带有 app-root 注释的 Ingress 规则:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/app-root: /app1
  name: approot
  namespace: default
spec:
  rules:
  - host: approot.bar.com
    http:
      paths:
      - backend:
          serviceName: http-svc
          servicePort: 80
        path: /
Run Code Online (Sandbox Code Playgroud)

检查重写是否有效

$ curl -I -k http://approot.bar.com/
HTTP/1.1 302 Moved Temporarily
Server: nginx/1.11.10
Date: Mon, 13 Mar 2017 14:57:15 GMT
Content-Type: text/html
Content-Length: …
Run Code Online (Sandbox Code Playgroud)

nginx kubernetes nginx-ingress

6
推荐指数
2
解决办法
4439
查看次数

ASP.NET Identity外部认证提供程序自定义图标

使用SimpleMembership,您可以向外部身份验证提供程序按钮添加一个图标,如下所示:

SimpleMembership:

Dictionary<string, object> FacebooksocialData = new Dictionary<string, object>();
FacebooksocialData.Add("Icon", "/content/images/gui/loginFacebook.png");
OAuthWebSecurity.RegisterFacebookClient(
    appId: "x",
    appSecret: "x",
    displayName: "Facebook",
    extraData: FacebooksocialData);
Run Code Online (Sandbox Code Playgroud)

然后在您的视图中将它们显示为:

@foreach (AuthenticationClientData p in Model)
{
    <button class="externalLoginService" style="cursor:pointer;color:transparent;border:none;background:url(@p.ExtraData["Icon"]);width:94px;height:93px;margin-right:20px;" type="submit" name="provider" value="@p.AuthenticationClient.ProviderName" title="Log in with @p.DisplayName">@p.DisplayName</button>
}
Run Code Online (Sandbox Code Playgroud)

ASP.NET标识(​​?):

app.UseFacebookAuthentication(
   appId: "x",
   appSecret: "x");
Run Code Online (Sandbox Code Playgroud)

如何使用ASP.NET Identity(控制器和视图)实现相同的功能?

asp.net openid oauth-2.0 simplemembership asp.net-identity

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

如何配置nginx.ingress.kubernetes.io/rewrite-target和spec.rules.http.paths.path以满足以下URI模式

如何配置nginx.ingress.kubernetes.io/rewrite-targetspec.rules.http.paths.path满足以下URI模式?

/aa/bb-aa/coolapp
/aa/bb-aa/coolapp/cc
Run Code Online (Sandbox Code Playgroud)

图例

  • a = az之间的任何字母。小写。恰好2个字母-不多也不少。
  • b = az之间的任何字母。小写。恰好2个字母-不多也不少。
  • c =任何有效的URI字符。小写。长度可变-认为。

示例URI:应该与上述模式匹配

/us/en-us/coolapp
/us/en-us/coolapp/faq
/us/en-us/coolapp/privacy-policy
Run Code Online (Sandbox Code Playgroud)

注意

从0.22.0版开始,使用注释的入口定义nginx.ingress.kubernetes.io/rewrite-target与以前的版本不向后兼容。在0.22.0版及更高版本中,必须在捕获组中显式定义请求URI中需要传递到重写路径的任何子字符串。

注意

捕获组都储存在编号占位符,按时间顺序,形式$1$2... $n。这些占位符可用作重写目标注释中的参数。

参考文献

  1. https://kubernetes.github.io/ingress-nginx/examples/rewrite/
  2. https://github.com/kubernetes/ingress-nginx/pull/3174

regex nginx kubernetes kubernetes-ingress nginx-ingress

5
推荐指数
2
解决办法
1083
查看次数

jwilder/nginx-proxy 和 kubernetes/ingress-nginx 有什么区别

jwilder/nginx-proxy 在 Docker Hub 上拥有 1.3K STARS 和 10M+ PULLS。以及 GitHub 上的 Watch 262、Star 7701、Fork 1546。 https://github.com/jwilder/nginx-proxy

kubernetes/ingress-nginx 在 kubeapps.com(星级最高的图表之一)上有 13 颗星,在 GitHub 上有 137 颗星、1596 颗星、918 颗星。 https://github.com/kubernetes/ingress-nginx

  1. 两者有什么区别?
  2. 你什么时候会使用其中一种而不是另一种?

nginx kubernetes jwilder-nginx-proxy kubernetes-ingress

4
推荐指数
1
解决办法
2416
查看次数

calc(.333*(100vw - 12em))是什么意思?

有人可以向我解释calc(.333 * (100vw - 12em))以下HTML行中的含义吗?特别是.333的价值; 它来自哪里?

sizes="(min-width: 36em) calc(.333 * (100vw - 12em)),
       100vw"
Run Code Online (Sandbox Code Playgroud)

摘自http://ericportis.com/posts/2014/srcset-sizes/

长度可以是各种各样的东西!长度可以是绝对的(例如99px,16em)或相对的(33.3vw,如我们的例子中所示).你会注意到,与我们的例子不同,有很多布局结合了绝对和相对单位.这就是令人惊讶的良好支持的calc()函数的用武之地.假设我们在3列布局中添加了12em侧边栏.我们会像这样调整尺寸属性:

sizes="(min-width: 36em) calc(.333 * (100vw - 12em)),
       100vw"
Run Code Online (Sandbox Code Playgroud)

我明白这一点:

  • (min-width:36em)=媒体查询
  • calc(.333*(100vw - 12em))=渲染图像大小
  • 100vw =默认渲染图像长度

html html5 responsive-design srcset responsive-images

3
推荐指数
1
解决办法
547
查看次数

如何找出我所属目录的全局管理员是谁

我已经检查了经典 Azure 门户中所有可能的区域,但似乎找不到我所属目录的“全局管理员”。

有没有办法在门户中找到这个?

azure azure-active-directory

3
推荐指数
1
解决办法
8295
查看次数

找出您在网站上运行的EPiServer版本的最快方法

除了episerver.config之外还有其他地方你可以找到该网站建立的EPiServer的版本("EPiServer 6"/"EPiServer 6 R2")吗?

通常我会查看episerver.config并将这些数字与Deployment Center中的数字进行比较,以确定它是"EPiServer 6"还是"EPiServer 6 R2".

我只使用过EPiServer 6和EPiServer 6 R2,因此这些版本与问题最相关.

编辑:更新了两个第一段,我的意思是单词版本.

episerver episerver-6 episerver-6-r2

2
推荐指数
1
解决办法
4271
查看次数

如何使用Azure存储客户端库.NET(BLOBS)列出所有虚拟目录和子目录

如何列出blob容器中的所有目录和子目录?

这是我到目前为止:

public List<CloudBlobDirectory> Folders { get; set; }

public List<CloudBlobDirectory> GetAllFoldersAndSubFoldersFromBlobStorageContainer()
{
    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
    CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
    CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");

    if (container.Exists())
    {
        Folders = new List<CloudBlobDirectory>();

        foreach (var item in container.ListBlobs())
        {
            if (item is CloudBlobDirectory)
            {
                var folder = (CloudBlobDirectory)item;
                Folders.Add(folder);
                GetSubFolders(folder);
            }
        }
    }

    return Folders;
}

private void GetSubFolders(CloudBlobDirectory folder)
{
    foreach (var item in folder.ListBlobs())
    {
        if (item is CloudBlobDirectory)
        {
            var subfolder = (CloudBlobDirectory)item;
            Folders.Add(subfolder);
            GetSubFolders(subfolder);
        }
    }
} …
Run Code Online (Sandbox Code Playgroud)

c# azure azure-storage azure-storage-blobs azure-sdk-.net

2
推荐指数
1
解决办法
2451
查看次数

如何将Gulp生成的dist文件夹包括在Visual Studio Build步骤创建的ProjectName.zip包中

我有一个构建定义,按以下顺序进行以下构建步骤:

  1. NuGet安装程序
  2. Npm
  3. 古尔普
  4. Visual Studio构建
  5. Azure Web App部署

在步骤3中,Gulp dist在我的应用程序根目录中生成一个文件夹。该dist文件夹包含一些子文件夹和文件。子文件夹本身可以包含其他子文件夹和文件。

在步骤4中,Visual Studio Build步骤<ProjectName>.zip完成后将创建一个zip文件。

然后,Azure Web App部署步骤将该zip文件部署到我的Azure Web App。

如何在其中包含dist文件夹<ProjectName>.zip

我尝试进行两个Azure Web App部署,一次以相同的构建定义部署一个zip文件,但是第二个Azure Web App Deployment生成步骤擦除了第一个部署的所有内容。有没有办法告诉第二个Azure Web App部署步骤“追加”到第一个Azure Web App部署步骤部署的内容

azure-devops

2
推荐指数
1
解决办法
1288
查看次数