小编Jas*_*ris的帖子

使用 Angular 动态添加和删除 <meta name="robots" content="noindex" />

Google Search Console 未对我的 Angular SPA 应用程序编制索引。Angular 团队在头部动态插入“noindex”元标记,并在页面渲染完成后,Angular 组件删除“noindex”元标记。据我了解,这种策略应该可以避免在 Angular 渲染网站之前对 SPA 建立索引,并避免对 404 页面建立索引。我遵循了与 Angular.io SPA 相同的方法,但我在 Google Search Console 中看到了不同的结果。

我的 SPA 是一个普通的 Angular CLI 项目,具有多个延迟加载的路由模块,并且延迟加载的路由模块中的组件负责删除“noindex”元标记。

显然谷歌正在索引 Angular.io 很好https://www.google.com/search?q=angular+router+-site%3A+angular.io

这是我的index.html

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Site Title</title>
  <meta name="description" content="My SEO meta description" />
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

  <script>
    // Dynamically, pre-emptively, add `noindex`, which will be removed when the doc is ready and valid
    tag = document.createElement('meta'); tag.name = 'robots'; …
Run Code Online (Sandbox Code Playgroud)

google-search-console angular

8
推荐指数
1
解决办法
4168
查看次数

实体框架5方法查询汇总

我试图通过查询SaleConfirmation表获得已确认/最终购买的摘要,但我在方法语法查询方面遇到了很多困难.

数据库表
这是存储最终销售额的SaleConfirmation表结构.

Id   OfferId   ProdId      Qty    SaleDate
-------------------------------------------------------
10   7         121518      150    2013-03-14 00:00:00.000
19   7         100518      35     2013-03-18 14:46:34.287
20   7         121518      805    2013-03-19 13:03:34.023
21   10        131541      10     2013-03-20 08:34:40.287
Run Code Online (Sandbox Code Playgroud)
  • Id:唯一的行ID.
  • OfferId:链接到Offer/Sale表的外键.
  • 产品:产品表中产品的ID.
  • 数量:销售给客户的数量.
  • SaleDate:销售最终确定的日期.

控制器动作

var confRollUps = db.SaleConfirmation
                  .GroupBy(c => c.OfferId) // Ensure we get a list of unique/distinct offers
                  .Select(g => g.Select(i => new {
                            i.OfferId, 
                            i.Product.Variety, // "Category" of product, will be the same across products for this offer. i.Product is a SQL …
Run Code Online (Sandbox Code Playgroud)

c# asp.net entity-framework anonymous-types asp.net-mvc-4

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