title: MVC 4 Why do i have to serialize on the server but not locally?
body: <p>The webserver on my hosting company keeps complaining that the class is not marked as [Serializable].</p>
  
  <p>When i run it on my localhost it works fine, no problem. As soon as i upload it to the server it asks me to serialize it?</p>
  
  <hr>
  
  <p>Example class:</p>
  
  <pre><code>public class Notification
  {
      public string Message { get; set; }
      public NotificationType NotificationType { get; set; }        
  
      public static Notification CreateSuccessNotification(string message)
      {
          return new Notification { Message = message, NotificationType = NotificationType.Success};
      }
  
      public static Notification CreateErrorNotification(string message)
      {
          return new Notification { Message = message, NotificationType = NotificationType.Error };
      }
  }
  </code></pre>
  
  <p>That i use in a base controller. This class is stored in TempData when a redirect to another method occurs, can this be the reason? But still, why on the server and not on my local computer?</p>
  
  <pre><code>public abstract class BaseController : Controller
  {
      protected override void OnActionExecuting(ActionExecutingContext filterContext)
          {
              _notifications = TempData["Notifications"] == null ? new List&lt;Notification&gt;() : (List&lt;Notification&gt;)TempData["Notifications"];
              _model = TempData["Model"];
              base.OnActionExecuting(filterContext);
          }
  
          protected override void OnResultExecuting(ResultExecutingContext filterContext)
          {
              if (filterContext.Result is RedirectToRouteResult)
              { 
                  if (_model != null)
                      TempData["Model"] = _model;
                  if (_notifications.Count &gt; 0)
                      TempData["Notifications"] = _notifications;
              }
  
              base.OnResultExecuting(filterContext);
          }
  }
  </code></pre>
  
  <p>The controller overriding this one just adds the notifications and a model if needed and then to a redirect to another action.</p>