在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) 我已经阅读文档一千次,但我仍然不明白我将如何使用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) 使用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(控制器和视图)实现相同的功能?
如何配置nginx.ingress.kubernetes.io/rewrite-target并spec.rules.http.paths.path满足以下URI模式?
/aa/bb-aa/coolapp
/aa/bb-aa/coolapp/cc
Run Code Online (Sandbox Code Playgroud)
图例:
示例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。这些占位符可用作重写目标注释中的参数。
参考文献:
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
有人可以向我解释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)
我明白这一点:
我已经检查了经典 Azure 门户中所有可能的区域,但似乎找不到我所属目录的“全局管理员”。
有没有办法在门户中找到这个?
除了episerver.config之外还有其他地方你可以找到该网站建立的EPiServer的版本("EPiServer 6"/"EPiServer 6 R2")吗?
通常我会查看episerver.config并将这些数字与Deployment Center中的数字进行比较,以确定它是"EPiServer 6"还是"EPiServer 6 R2".
我只使用过EPiServer 6和EPiServer 6 R2,因此这些版本与问题最相关.
编辑:更新了两个第一段,我的意思是单词版本.
如何列出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) 我有一个构建定义,按以下顺序进行以下构建步骤:
在步骤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部署步骤部署的内容?
kubernetes ×3
nginx ×3
azure ×2
asp.net ×1
asp.net-mvc ×1
azure-devops ×1
c# ×1
episerver ×1
episerver-6 ×1
html ×1
html5 ×1
lazy-loading ×1
oauth-2.0 ×1
openid ×1
regex ×1
srcset ×1