iis - LD-JSON 导致 Web 应用程序错误
问题描述
我有一个在 .netcore 2.0 中创建的网站,当我将 schema.org 标记添加到网站时,它会为网站返回 404 错误。
例如在正文底部添加以下代码
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "http://website.com",
"name": "wbs",
"description": "Web Studio"
}
</script>
它返回 404 错误。如果我删除该 ld-json,那么网站将正常运行。
我将网站托管在运行 IIS 8 的 Windows 服务器机器上;与 IIS 设置有关吗?
解决方案
一旦我将代码放入 IDE 中,答案就很明显了,我忘记了躲避@
in razor。
所以代码
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "http://website.com",
"name": "wbs",
"description": "Web Studio"
}
</script>
会成为:
<script type="application/ld+json">
{
"@@context": "http://schema.org",
"@@type": "WebSite",
"url": "http://website.com",
"name": "wbs",
"description": "Web Studio"
}
</script>
推荐阅读
- google-apps-script - 如何在不过期的情况下向 Google 应用脚本添加授权?
- python - 加载对于 RAM 来说太大的 .npy 文件
- javascript - Loopback findOne 无法正确搜索 MongoDB
- c - 在 C 中使用 strcpy() 函数
- python - 从 one-hot 编码输入顺序添加工作日
- mysql - Vertx mysql一一插入多行以捕获任何成功和错误
- flutter - ScrollController 附加到多个滚动视图。扑
- ios - 如何减少 AVPlayer 播放视频的初始缓冲时间?
- javascript - 将“选择/选项”的选定值从 HTML 解析为 php
- python - 气流 - 在 for 循环最终任务之后插入任务依赖