title: Model Null reference exception in mvc view
body: <p>The problem is getting null reference exception when passing data from controller to view</p>
  
  <p>I am Passing a model to the view from the controller like this:</p>
  
  <pre><code> {
      ViewBag.PartId = id;
      var viewmodel= new Orderviewmodelnew();
      var order = new OrderMnagernew().GetSingleOrderField(id);
      viewmodel.ProjectId=order.ProjectId;
      return View(viewmodel);
   }
  </code></pre>
  
  <p>And in the View I have code like this</p>
  
  <pre><code> @model DreamTrade.Web.BL.ViewModels.OrderViewModelnew
  
  
   Home&gt;Project @Model.ProjectID==null??//projected is of type guid
  
   Customer :@(Model.CreatedBy??string.empty)
  
   Project :@Model.ProjectID
       @Model.ProjectDetail
  
    CreatedBy:@Model.CreatedBy
  
    Creation Date:@Model.CreationDate
  
   CompletedBy :@Model.ModifiedBy
   Completion Date:@Model.LastModified
  
   @Model.Image
  
     @Html.Action("OrderIndex", "Ordernew", new { PartId = Guid.Parse("C0497A40-2ADE-4B23-BA9F-1694F087C3D0") })
  </code></pre>
  
  <p>I have Tried like this</p>
  
  <pre><code>@if(Model.ProjectId==Null)
   {/....}
  </code></pre>
  
  <p>In the controller i tried like this by not passing model if it is null</p>
  
  <pre><code> var order = new OrderMnagernew().GetSingleOrderField(id);
      if(order!=null)
     {
          viewmodel.ProjectId=order.ProjectId;
          return View(viewmodel);
  
     }
   return View()
  </code></pre>
  
  <p>The problem with this the projectid in the view is showing exception.</p>
  
  <p>I Want to display empty string if it is null and show the remaining part..</p>