|
Rank: Newbie Joined: 2/8/2012 Posts: 5 Location: Alexandria,VA
|
If I am logged in the http://www.computerhelpsos.com:8040/AutoHostEmail.ashx/?Email=xxx@yahoo.com works now. But if I am not logged in (and I should not be logged in) I get the following Trace: Quote: [SecurityException: Needs permission.] Elsinore.ScreenConnect.Permissions.AssertPermission(PermissionRequest request, IEnumerable`1 entries, Boolean throwOrEnd) +156 CreateSession.CreateSessionEmail(Guid sessionID, String xEmail) +114 CreateSession.ProcessRequest(HttpContext context) +196 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +586 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +177
Here is the full code so far, the response redirect is also not working yet. Quote:
<%@ WebHandler Language="C#" Class="CreateSession" %>
using System; using System.Net.Mail; using System.Web; using System.Collections.Generic; using System.Linq; using System.Configuration; using Elsinore.ScreenConnect; using SmtpClient = Elsinore.ScreenConnect.SmtpClient;
public class CreateSession : IHttpHandler { private string sessionCode = "Email "+DateTime.Now; object CreateEmail(string overrideFrom, string to, string subjectFormat, string bodyFormat, bool isBodyHtml, bool send, string overrideRelayHost, params object[] formatParams) { var mailMessage = new MailMessage(); //to = "computerhelpsos@gmail.com"; if (overrideFrom != null) mailMessage.From = new MailAddress(overrideFrom);
mailMessage.To.Add(to); mailMessage.Subject = string.Format(subjectFormat, formatParams); mailMessage.Body = string.Format(bodyFormat, formatParams); mailMessage.IsBodyHtml = isBodyHtml;
if (send) { var client = new SmtpClient();
if (overrideRelayHost != null) client.Host = overrideRelayHost;
client.Send(mailMessage); } return new { sent = send, from = mailMessage.From.Address, to = mailMessage.To[0].Address, subject = mailMessage.Subject, body = mailMessage.Body }; } public object CreateSessionEmail(Guid sessionID,string xEmail) { Permissions.AssertPermission(new PermissionRequest { Name = PermissionInfo.CreateAttendedSessionPermission }, true);
using (var sessionManager = ServiceChannelPool<ISessionManagerChannel>.Instance.Borrow()) { var sessionSummary = sessionManager.GetSessionSummary(sessionID); var webServerUri = ServerExtensions.GetWebServerUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, false); var sessionGuestUrl = Extensions.EncodeUrl(webServerUri.Uri.AbsoluteUri, ServerConstants.SessionIDParameterName, sessionSummary.SessionID); var send = !Convert.ToBoolean(ConfigurationManager.AppSettings[ServerConstants.SmtpUseClientSettingsKey]); var isBodyHtml = Convert.ToBoolean(global::Resources.Default.CreateSessionPanel_EmailBodyIsHtml);
return this.CreateEmail(null, xEmail, global::Resources.Default.CreateSessionPanel_EmailSubject, global::Resources.Default.CreateSessionPanel_EmailBody, isBodyHtml, send, null, sessionSummary.Host, sessionGuestUrl); } } public void ProcessRequest(HttpContext context) { var email = context.Request.QueryString["Email"]; //context.Response.Redirect("Guest.aspx"); using (var sessionManager = ServiceChannelPool<ISessionManagerChannel>.Instance.Borrow()) { var session = sessionManager.CreateSession(InvitationType.Email, sessionCode,email ); CreateSessionEmail(session.SessionID,email);
context.Server.TransferRequest("Guest.aspx"); } }
public bool IsReusable { get { throw new NotImplementedException(); } }
}
|