Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Data;
- using System.Web.Mvc;
- using System.Web.Routing;
- using System.Xml;
- using Legend3_Shared.MySQL;
- using MySql.Data.MySqlClient;
- namespace VoxelPro_WebSite
- {
- public class MvcApplication : System.Web.HttpApplication
- {
- public static MySqlConnection Connection = new MySqlConnection("YOUR_CONNECTION_STRING");
- protected void Application_Start()
- {
- if (Connection.State == ConnectionState.Closed)
- Connection.Open();
- Connection.Query("select Value from counters where name='Visits'", r =>
- {
- var result = r["Value"];
- Application["Visits"] = (long) result;
- return false;
- });
- AreaRegistration.RegisterAllAreas();
- RouteConfig.RegisterRoutes(RouteTable.Routes);
- Connection.Close();
- }
- private void Session_Start(object sender, EventArgs e)
- {
- if (Connection.State == ConnectionState.Closed)
- Connection.Open();
- Connection.NonQuery($"update counters set Value={visits+1} where name='Vists'");
- Connection.Close();
- }
- private void Session_End(object sender, EventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement