title: .NET Must Specify Valid Information?
body: <p>This piece of code works fine elsewhere, the only thing that's changed is its now in a loop and I'm calling variables by item. instead of model. When I pre-define <code>newurl</code> and page content contains the code works and it parses lives as "Live" which is correct so I feel its something to do with this? However I'm getting the error below:</p>
  
  <blockquote>
    <p>Exception Details: System.ArgumentException: Must specify valid information for parsing in the string.</p>
  </blockquote>
  
  <p>On this line:</p>
  
  <pre><code>lives = "Live";
  </code></pre>
  
  <p>I did have this after:</p>
  
  <pre><code>else
  {
      lives = "Dead";
  }
  </code></pre>
  
  <p>However, I removed it to find the error as otherwise it just parses and sets the variable as dead.</p>
  
  <h3>Enum</h3>
  
  <pre><code>public enum Live
  {
      Indexed, Live, Dead
  }
  </code></pre>
  
  <p>Though it shows that its something to do with the variables? I tried setting another variable of the object to the <code>newurl</code> string to check it was correct and it is. I also tried predefining <code>newurl</code> but not page contains and it still doesn't work so its an issue with both of these?</p>
  
  <p>So I know that <code>item.Anchor</code> etc are pulling in the variables correctly it just doesn't seem to translate to working?</p>
  
  <h3>Code</h3>
  
  <pre><code>public ActionResult CheckLinks(Link model)
  {
      var items = db.Links.Where(p =&gt; p.UserTable.ID == UserTableID).ToList();
      foreach (var item in items)
      {
          string pageContent = null;
          string visiturl = "http://webcache.googleusercontent.com/search?q=cache:" + "http://" + item.Identifier.domain + item.Obdomain;
          HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(visiturl);
          HttpWebResponse myres = (HttpWebResponse)myReq.GetResponse();
  
          using (StreamReader sr = new StreamReader(myres.GetResponseStream()))
          {
              pageContent = sr.ReadToEnd();
          }
          string lives = "";
          if (pageContent.Contains(item.Anchor))
          {
              lives = "Indexed";
          }
          else
          {
              string newurl = "http://" + item.Identifier.domain + item.Obdomain;
              HttpWebRequest newReq = (HttpWebRequest)WebRequest.Create(newurl);
              HttpWebResponse newres = (HttpWebResponse)newReq.GetResponse();
  
              using (StreamReader sr = new StreamReader(newres.GetResponseStream()))
              {
                  pageContent = sr.ReadToEnd();
              }
              if (pageContent.Contains(item.Anchor))
              {
                  lives = "Live";
              }
  
              var link = db.Links.SingleOrDefault(c =&gt; c.LinkID == item.LinkID);
              link.live = (Link.Live)Enum.Parse(typeof(Link.Live), lives);
              db.Entry(link).State = EntityState.Modified;
          }
          db.SaveChanges();
      }
      return RedirectToAction("Index");
  }
  </code></pre>