c# - 使用 AMP 项目和 Razor 页面的页面加载 8 次
问题描述
在这个使用 Razor 页面的最小 AMP HTML 页面(参见http://ampproject.com)中,每次加载页面时都会多次点击 OnGet 中的断点(通常是 8 次)。为什么会这样?谁能告诉我出了什么问题?先感谢您。
这里是c#。
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace iVoterGuide.com.Pages {
public class IndexModel : PageModel {
public void OnGet() {
// ***** The breakpoint is set here
}
}
}
这是cshtml。如您所见,它仅包含 AMP 所需的最少脚本和其他内容,以及“TEST BODY”内容。
@page
@model iVoterGuide.com.Pages.IndexModel
@{
Layout = null;
}
<!DOCTYPE html>
<html ⚡>
<head>
<meta charset="utf-8">
<link rel="canonical" href="IndexWholePage.cshtml">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/>
<title>IndexWholePage</title>
<!-- Structured Data
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<!-- JSON-LD -->
<script type="application/ld+json">
{
"@@context": "http://schema.org",
"@@type": "NewsArticle",
"headline": "page title",
"datePublished": "2018-05-19 14:52",
"image": [
"logo.jpg"
]
}
</script>
<!-- Facebook -->
<meta property="og:url" content="page url" />
<meta property="og:title" content="page title" />
<meta property="og:image" content="document image" />
<meta property="og:description" content="document description" />
<meta property="og:site_name" content="iVoterGuide" />
<meta property="og:type" content="article" />
<meta property="og:locale" content="en_US" />
<meta property="og:fb:app_id" content="" />
<!-- Twitter -->
<meta name="twitter:site" content="@@iVoterGuide" />
<meta name="twitter:creator" content=" " />
<!-- Boilerplate Scripts/Styles
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style>
<noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<!-- Fonts & Icons
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link href="https://fonts.googleapis.com/css?family=Roboto:200,300,400,500,700" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script async src="https://cdn.ampproject.org/v0.js"></script>
</head>
<body>
<h1>TEST BODY</h1>
</body>
</html>
如果我从 ⚡ 中删除,那么一切正常。
编辑:简化并更新了问题。
解决方案
推荐阅读
- angular - Angular 发出 http get 请求,然后使用 get 请求中的数据发出 put 请求
- javascript - Get from hls.js response code and message from playlist.m3u8
- java - 当类包含接口类型的变量时,如何通过杰克逊进行序列化/反序列化?
- c - 在 C 中打印数字
- javascript - 在 ReactJS 中渲染组件数组
- google-apps-script - onclick 动作完成执行后返回
- python - 适用于 Windows 和 Linux 的 VS 代码 PYTHONPATH
- javascript - DOM 只注册一键点击事件移除元素
- python - 使用 json 数据初始化 Python 变量
- node.js - 为什么我们在 http.createServer(app) 中传递“app”