Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8826263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:05:38+00:00 2026-06-14T07:05:38+00:00

I am using asp.net Webmatrix-Razor. I am also using HTMLAgilityPack. I am parsing meta

  • 0

I am using asp.net Webmatrix-Razor. I am also using HTMLAgilityPack. I am parsing meta tags to grab the Facebook meta tags from website to post to my site. the code works on all websites except when I try to grab a news article from the Huffington Post. I get “System.NullReferenceException: Object reference not set to an instance of an object.” The error happens at the line with select new. The site does have Facebook meta Tags. there is this meta tag which I heard might cause an issue not sure though.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >

Here is the code;

    var webGet = new HtmlWeb();   
    var document = webGet.Load(Request.Form["news_URL"]);
    var metaTags = document.DocumentNode.SelectNodes(".//meta");
    if (metaTags != null){
        var metaOnPage = from lnks in document.DocumentNode.Descendants()
                where lnks.Name == "meta" && 
                lnks.Attributes["property"] != null
                //lnks.InnerText.Trim().Length > 0
                select new
                {
                metaName = lnks.Attributes["property"].Value,
                metaContent = lnks.Attributes["content"].Value
                };

        var Title = "";
        var URL = "";
        var imgSRC = "";
        var Description = "";
        foreach(var i in metaOnPage){

        if(i.metaName == "og:title"){
            Title = i.metaContent;
        }else if(i.metaName == "og:url"){
            URL = i.metaContent;
        }else if(i.metaName == "og:image"){
            imgSRC = i.metaContent;
        }else if(i.metaName == "og:description"){
            Description = i.metaContent;
        }

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:05:39+00:00Added an answer on June 14, 2026 at 7:05 am

    Seems likely that this expression is the problem: lnks.Attributes["content"].Value. You’ve checked that “property” exists, but not “content”. Maybe you want to add the check, since your code seems to assume that content contains something:

    lnks.Attributes["property"] != null && lnks.Attributes["content"] != null
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Microsoft WebMatrix to develop a small website in ASP.NET Web Pages. I
i have some problem here with Edit Data Using ASP.NET Razor in WebMatrix i
i have some problem here with Edit Data Using ASP.NET Razor in WebMatrix i
So does the new ASP.NET web pages (also called razor pages) framework using the
I'm learning ASP.Net web pages programming using Webmatrix (with razor syntax). Goal is to
Using ASP.NET, how can I strip the HTML tags from a given string reliably
Using ASP.NET MVC when trying to get the information stored on my Session[objectName] from
I'm trying to submit form data with jQuery. I'm using ASP.NET WebMatrix. In a
I have developed a website using Asp.Net MVC which uses a SQL CE database
Using ASP.NET MVC can be used the view engine Razor. Razor let you use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.