我有以下剃须刀,但是如果我直接转到网址,它会抛出一个空引用。我查看了Request.Url.Host,这些部分都不是null,可能是什么问题:
@{
Layout = "NoNavigationMaster.cshtml";
var brand = Common.GetProductBrand(Request.Url.Host);
if (brand == BrandType.SCT)
{
<style type="text/css">
div.products-filter-overlay-body div.bg-image {
position: absolute;
height: 100%;
width: 100%;
bottom: 0;
top: 0;
left: 0;
right: 0;
background: url(overlay-bg@2x.jpg) no-repeat center center fixed;
background-size: cover;
}
</style>
}
else if(brand == BrandType.BullyDog)
{
<style type="text/css">
div.products-filter-overlay-body div.bg-image {
position: absolute;
height: 100%;
width: 100%;
bottom: 0;
top: 0;
left: 0;
right: 0;
background: url(bd-products-filter-overlay-bg@2x.jpg) no-repeat center center fixed;
background-size: cover;
}
</style>
}
}
答案 0 :(得分:0)
不知道Common.GetProductBrand方法的主体很难分辨。可能是剃须刀@ 2x是空的。给它们设一个断点并检查它们的值