HtmlMeta tagimg = new HtmlMeta();
tagimg.Attributes.Add("property", "og:img");
tagimg.Content = imgAddress;
Page.Header.Controls.Add(tagimg);
I wrote above code in Page_load()
thanks
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I have a List of Products with Title, Photo and some other contents.
When I click on Details link it shows me details of selected Product with Image.
I want to add this dynamic loaded image in meta tag for "og:image" - og tags
I tried it but I unable to set image URL in meta tag.
Photo field is string type i am storing URL here.
asp.net web forms - C#
Thanks
HtmlMeta tagimg = new HtmlMeta();
tagimg.Attributes.Add("property", "og:img");
tagimg.Content = imgAddress;
Page.Header.Controls.Add(tagimg);
I wrote above code in Page_load()
thanks
HI
thanks for reply.
No I am not getting any error message. But og:image is not showing on whatsapp. I tried below tests.
Tests:
1] Response.Write("<meta property='og:image' content=" + imgAdd + " itemprop='image'>");
2] Response.Write("<meta property='og:image:secure_url' content=" + imgAdd + " itemprop='image'>");
3] Response.Write("<meta property='og:image' content=" + imgAdd + " itemprop='image'>");
imgAdd is the variable where I stored sent Image url.
I removed my previous code which I mentioned above in Page_Load
Hi @WebForm_Developer ,
I tried your code, the problem is the missing quotes.
Response.Write("<meta property='og:image' content=" + imgAdd + " itemprop='image'>");
output:
HtmlMeta tagimg = new HtmlMeta();
tagimg.Attributes.Add("property", "og:img");
tagimg.Content = imgAddress;
Page.Header.Controls.Add(tagimg);
output:
You can see the difference by looking at the output above.You can see the difference by looking at the output above, so you need to put single quotes around the content.**content='" + imgAdd + "'**
.
Response.Write("<meta property='og:image' content='" + imgAdd + "' itemprop='image'/>");
output
If you have extra questions about this answer, please click .
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
No. Still not working....
Updated code:
Response.Write("<meta property='og:image' content='" + imgAdd + "' itemprop='image'>");
Response.Write("<meta property='og:image:secure_url' content='" + imgAdd + "' itemprop='image'>");
It's working very fine if I paste the URL on facebook or send SMS. Only problem while sending with whatsapp