我没有AspDotNetStorefront平台的经验,所以我需要帮助设置包。XML包代码在
下面<?xml version="1.0" standalone="yes" ?>
<package version="2.1" displayname="BFGs canonical package" debug="false" includeentityhelper="false" allowengine="true">
<query name="Products" rowElementName="Product">
<sql>
<![CDATA[
SELECT ProductID, Name, SEName FROM Product WHERE ProductID = @ProductID
]]>
</sql>
<queryparam paramname="@ProductID" paramtype="request" requestparamname="ProductID" sqlDataType="int" defvalue="0" validationpattern="^d{1,10}$" />
</query>
<query name="Categories" rowElementName="Category">
<sql>
<![CDATA[
SELECT CategoryID, Name, SEName FROM Category WHERE CategoryID = @CategoryID
]]>
</sql>
<queryparam paramname="@CategoryID" paramtype="request" requestparamname="CategoryID" sqlDataType="int" defvalue="0" validationpattern="^d{1,10}$" />
</query>
<PackageTransform>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aspdnsf="urn:aspdnsf" exclude-result-prefixes="aspdnsf">
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:template match="/">
<xsl:param name="site">https://www.tapestrymusic.com/</xsl:param>
<xsl:param name="canonical">
<xsl:choose>
<xsl:when test="/root/Categories/Category/CategoryID > 0 and (/root/QueryString/pagenum > 1)"><xsl:value-of select="$site"/>c-<xsl:value-of select="/root/Categories/Category/CategoryID"/>-<xsl:value-of select="/root/Categories/Category/SEName"/>.aspx?pagenum=<xsl:value-of select="/root/QueryString/pagenum"/></xsl:when>
<xsl:when test="/root/Categories/Category/CategoryID > 0"><xsl:value-of select="$site"/>c-<xsl:value-of select="/root/Categories/Category/CategoryID"/>-<xsl:value-of select="/root/Categories/Category/SEName"/>.aspx</xsl:when>
<xsl:when test="/root/Products/Product/ProductID > 0"><xsl:value-of select="$site"/>p-<xsl:value-of select="/root/Products/Product/ProductID"/>-<xsl:value-of select="/root/Products/Product/SEName"/>.aspx</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:choose>
<xsl:when test="$canonical != 0">
<link rel="canonical" href="{$canonical}" />
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:template>0
</xsl:stylesheet>
</PackageTransform>
</package>
和I _Head。cshtml我添加到像这样
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@Html.XmlPackage("Canonical")
<link rel="preconnect" href="https://fonts.googleapis.com">
但是我得到的是空值
<!--Xmlpackage 'Canonical' -->
<!--End of xmlpackage 'Canonical' -->
我想在这两个注释之间加上<link rel="canonical" href="domain.com">
答案是@Html.XmlPackage("canonical.xml.config")
放进去,它会显示在页首