C
cschnick@premier-us.net
Guest
I am needing to redirect a user to a specific page after they have logged in and I know what type of user they are based on custom profile settings we have. The hook for ILoginCompletedEvent is working fine. I get to the LoginCompletedEventVerification method when I would expect to. The custom profile part "PTL_Extensions.Security.IsClient(userIDGuid)" is working fine. The redirect is where I need some assistance. I have found and followed the guidance given in the following two articles: HOW TO REDIRECT TO SPECIFIC PAGE UPON LOGIN Progress KB - How to redirect to specific page upon login and ILoginCompletedEvent FOR DEVELOPERS ILoginCompletedEvent - Sitefinity CMS Utilities and services My LoginCompletedEventVerification method is as follows: private void LoginCompletedEventVerification(ILoginCompletedEvent evt) { if (evt.LoginResult == UserLoggingReason.Success) { var userName = evt.Username; var userEmail = evt.Email; var userIDGuid = Guid.Parse(evt.UserId); var userIP = evt.IpAddress; //if (!PTL_Extensions.Security.IsEmployee(currentUser.Id)) if (PTL_Extensions.Security.IsEmployee(userIDGuid)) { // redirect to Legacy Premier iFrame page Response.Redirect("/my-premier/my-premier-legacy"); } else if (PTL_Extensions.Security.IsClient(userIDGuid)) { // redirect to Client Dashboard Response.Redirect("/my-premier/customer-dashboard"); } else { //redirect to Home Page } } } If I uncomment the Response.Redirect("/my-premier/customer-dashboard"); lines, I get the following exception: Server Error in '/' Application. Response is not available in this context. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: Response is not available in this context. Source Error: Line 104: { Line 105: // redirect to Legacy Premier iFrame page Line 106: Response.Redirect("/my-premier/my-premier-legacy"); Line 107: } Line 108: else if (PTL_Extensions.Security.IsClient(userIDGuid)) Source File: C:\PTL\POC\PTL_POC\Global.asax.cs Line: 106 Stack Trace: [HttpException (0x80004005): Response is not available in this context.] System.Web.HttpApplication.get_Response() +9983123 SitefinityWebApp.Global.LoginCompletedEventVerification(ILoginCompletedEvent evt) in C:\PTL\POC\PTL_POC\Global.asax.cs:106 [TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +160 System.Delegate.DynamicInvokeImpl(Object[] args) +117 Telerik.Sitefinity.Services.Events.HandlerList.Invoke(IEvent event, Boolean throwExceptions) +186 [EventHandlerInvocationException: Response is not available in this context.] Telerik.Sitefinity.Owin.Extensions. d__1.MoveNext() +324 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 Telerik.Sitefinity.Owin. d__1.MoveNext() +217 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 Microsoft.Owin.Host.SystemWeb.IntegratedPipeline. d__5.MoveNext() +182 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 Microsoft.Owin.Host.SystemWeb.IntegratedPipeline. d__2.MoveNext() +180 Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar) +69 Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar) +65 System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +380 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +48 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +159
Continue reading...
Continue reading...