为什么 @url.content()对我不起作用(.net 5)
我想在剃须刀视图上使用 @url.content获取静态文件的绝对路径,以将其用作元标记的内容属性的值,但似乎对我不起作用,我不知道问题是什么。
@{
var pageThumbnail = Url.Content("~/assets/121545/mid.jpg");
}
@section Meta {
<meta property="og:image" content="@pageThumbnail" />
}
结果:
&lt; meta属性=“ og:image” content =“/assets/121545/mid.jpg”/&gt;
我期望此结果:
&lt; meta property =“ og:image” content =“ https:// localhost:5001/assets/121545/mid.jpg”/&gt;
I want to get the absolute path of a static file using @Url.Content on a razor view to use it as a value of content attr of a meta tag but It's seems not working for me I didn't know what is the problem.
@{
var pageThumbnail = Url.Content("~/assets/121545/mid.jpg");
}
@section Meta {
<meta property="og:image" content="@pageThumbnail" />
}
Result :
<meta property="og:image" content="/assets/121545/mid.jpg" />
I expected this result instead:
<meta property="og:image" content="https://localhost:5001/assets/121545/mid.jpg" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将
context.request.host
添加到pagethumbnail
:Try to add
Context.Request.Host
topageThumbnail
: