title: Passing Iterated list of values from controller to view in Asp.net mvc 4
body: <p>I have a controller which checks for list of urls and returns the httpstatus code, description and message to the view. Everytime i debug my solution it goes through the list of urls but it only returns the status of first url.</p>
  
  <p>How can i return the status of all the list of urls? Here is my sample code </p>
  
  <pre><code>        {
  
          string[] urls = {
        "http://www.google.com","http://www.34q34adf.com","http://aldlfaldkfk.com","http://www.bbc.com"
  
                          };
  
          foreach (string url in urls)
  
          {
              try
              {
  
  
                  HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
  
  
                  HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
  
                  ViewBag.status_code = ((int)myHttpWebResponse.StatusCode);
                  ViewBag.status_desc = myHttpWebResponse.StatusDescription;
                  var current_code = ((int)myHttpWebResponse.StatusCode);
  
                  if (current_code == 200)
                  {
                      ViewBag.Image = "Images/green_light.png";
                      ViewBag.AlertType = "alert-success";
                  }
  
                  myHttpWebResponse.Close();
  
              }
              catch (WebException e)
              {
                  string message = e.Message;
  
                  if (e.Status == WebExceptionStatus.ProtocolError)
                  {
                      HttpWebResponse hwr = (HttpWebResponse)e.Response;
  
                      ViewBag.status_code = ((int)hwr.StatusCode);
                      ViewBag.status_desc = hwr.StatusDescription;
                      var current_code = ((int)hwr.StatusCode);
                      ViewBag.status_desc = hwr.StatusDescription;
                      if (current_code != 200)
                      {
                          ViewBag.Image = "Images/red_light.png";
                          ViewBag.AlertType = "alert-error";
                      }
                  }
              }
              catch (Exception e)
              {
                  ViewBag.message = e.Message;
              }
          }
  
          return View();
      }
  </code></pre>
  
  <p>How can i make my view display the status of all the urls? Any help will really be appreciated.</p>