title: Response Redirect Using In MVC
body: <p>I want to create connection between global.asax and my controller. We are using a database in our website. We have a code to check whether the database exists or not. If it doesn't not exist, we want to display a message like "database initializing" etc.. </p>
  
  <p>Database check in <strong>GLOBAL.ASAX</strong> : </p>
  
  <pre><code>public class MvcApplication : System.Web.HttpApplication
  {
      public static bool flag;
      protected void Application_Start()
      {
          Database.SetInitializer&lt;PhoneDexContext&gt;(null);
  
          var connString = ConfigurationManager.ConnectionStrings["DatabaseConnection"].ConnectionString;
  
          using (PhoneDexContext db = new PhoneDexContext())
          {
              if (!db.Database.Exists())
              {
                  flag = true;
                  db.Database.CreateIfNotExists();              
              }
  
          }
  
          AreaRegistration.RegisterAllAreas();
          FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
          RouteConfig.RegisterRoutes(RouteTable.Routes);
          BundleConfig.RegisterBundles(BundleTable.Bundles);
      }
  
      protected void Application_BeginRequest()
      {
          if (flag)
          {
              Response.Redirect("Loading/LoadingScreen");
          }
      }
  }
  </code></pre>
  
  <p>But we have a problem with using response redirect. It returns </p>
  
  <blockquote>
    <p>{"Response is not available in this context."}.</p>
  </blockquote>
  
  <p>We have a controller which is LoadingController and it has this code;</p>
  
  <pre><code>public class LoadingController : Controller
  {
      // GET: Loading
      public ActionResult LoadingScreen()
      {
  
          return View();
      }
  }
  </code></pre>
  
  <p>But we can't jump to this part. How can i make connection?? Thanks</p>