public void announceStatusChange() { string userip = null; userip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (userip == null) userip = Request.ServerVariables["REMOTE_ADDR"]; string signalr_hub = "http://localhost:" + Request.Url.Port + VirtualPathUtility.ToAbsolute("~/signalr/hubs"); try { // create a new connection if one does not exist if (hubConnection == null || hubConnection.State == Microsoft.AspNet.SignalR.Client.ConnectionState.Disconnected) { hubConnection = new HubConnection(signalr_hub); // Create a proxy to the chat service hub = hubConnection.CreateHubProxy("visitorUpdate"); // Start the connection hubConnection.Start().Wait(); } if (hubConnection.State == Microsoft.AspNet.SignalR.Client.ConnectionState.Connected) { // Send the message String user_ip = Request.UserHostAddress; hub.Invoke("AnnounceStatusChange", user_ip); hubConnection.Stop(); } } catch (Exception ex) { Core.Model.Contact msg = new Core.Model.Contact(); string hub_state = ""; if (hubConnection != null) { hub_state = hubConnection.State.ToString(); } else { hub_state = "null"; } msg.Message = "account controller. <br />state: " + hub_state + "<br><br>" + ex.Message.ToString(); if (ex.InnerException != null) { msg.Message = msg.Message + "<br><br>" + ex.InnerException.Message.ToString(); } _mailService.SendContact(msg.Message, msg.Email); } }
public ActionResult HttpError() { Exception ex = null; Boolean handled = false; string errorPage = ""; try { ex = (Exception)HttpContext.Application[Request.UserHostAddress.ToString()]; errorPage = (string)HttpContext.Application[Request.UserHostAddress.ToString() + "-address"]; } catch (Exception exa) { ex = new Exception("Unable to pull exception details."); } // we want to ignore some errors, to prevent from being spammed ot all hell if (ex.Message.Contains("e8f6b078-0f35-11de-85c5-efc5ef23aa1f/aupm/notify.do") == true) { return View("Error"); } if (ex.Message.Contains("/crossdomain.xml") == true) { return View("Error"); } if (ex.Message.Contains("The connection id is in the incorrect format") == true) { return View("Error"); } if (ex.Message.Contains("The controller for path '/post/")) { String path = Request.RawUrl.Replace("/error?aspxerrorpath=", ""); Response.Redirect("http://crushes.tumblr.com" + path); handled = true; } Core.Model.Contact msg = new Core.Model.Contact(); msg.Email = "*****@*****.**"; string errorMessage = String.Format("page: {0} <br /><br />{1}", errorPage, ex.Message.ToString()); msg.Message = errorMessage; if(ex.InnerException != null) { msg.Message = msg.Message + "<br><br>" + ex.InnerException.Message.ToString(); ViewData["Inner"] = ex.InnerException.Message.ToString(); } if (ex.StackTrace != null) { msg.Message = msg.Message + "<br><br>Stack trace:<br/><code>" + ex.StackTrace.ToString() + "</code>"; } if (handled == false) { _mailService.SendContact(msg.Message, msg.Email); } if (ex != null) { ViewData["Description"] = ex.Message; } else { ViewData["Description"] = "An error occurred."; } ViewData["Title"] = "Oops. We're sorry. An error occurred and we're on the case."; return View("Error"); }