当前位置: 首页>>代码示例>>C#>>正文


C# NancyContext.GetRedirect方法代码示例

本文整理汇总了C#中Nancy.NancyContext.GetRedirect方法的典型用法代码示例。如果您正苦于以下问题:C# NancyContext.GetRedirect方法的具体用法?C# NancyContext.GetRedirect怎么用?C# NancyContext.GetRedirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nancy.NancyContext的用法示例。


在下文中一共展示了NancyContext.GetRedirect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LogOutAndRedirectResponse

        /// <summary>
        /// Logs the user out and redirects them to a URL
        /// </summary>
        /// <param name="context">Current context</param>
        /// <param name="redirectUrl">URL to redirect to</param>
        /// <returns>Nancy response</returns>
        public static Response LogOutAndRedirectResponse(NancyContext context, string redirectUrl)
        {
            var response = context.GetRedirect(redirectUrl);
            var authenticationCookie = BuildLogoutCookie(currentConfiguration);
            response.AddCookie(authenticationCookie);

            return response;
        }
开发者ID:ross2411,项目名称:Ideastrike,代码行数:14,代码来源:FormsAuthentication.cs

示例2: SetCurrentUserToViewBag

        private Response SetCurrentUserToViewBag(NancyContext ctx)
        {
            var author = _viewProjectionFactory.Get<string, Author>(ctx.CurrentUser.UserName);
            if (author == null)
                return ctx.GetRedirect("/mz-login?returnUrl=" + Request.Url.Path).WithCookie(FormsAuthentication.CreateLogoutCookie());

            ViewBag.CurrentUser = author;
            return null;
        }
开发者ID:iloveyouzlw,项目名称:MZBlog,代码行数:9,代码来源:SecureModule.cs

示例3: SetContextUserFromAuthenticationCookie

        private Response SetContextUserFromAuthenticationCookie(NancyContext ctx)
        {
            var username = FormsAuthentication.GetAuthUsernameFromCookie(ctx);

            if (username.IsNullOrWhitespace())
                return ctx.GetRedirect("/mz-login?returnUrl=" + Request.Url.Path).WithCookie(FormsAuthentication.CreateLogoutCookie());

            ctx.CurrentUser = new BlogUserIdentity(username, new string[] {"admin" });

            return null;
        }
开发者ID:iloveyouzlw,项目名称:MZBlog,代码行数:11,代码来源:SecureModule.cs

示例4: UserLoggedInRedirectResponse

        /// <summary>
        /// Creates a response that sets the authentication cookie and redirects
        /// the user back to where they came from.
        /// </summary>
        /// <param name="context">Current context</param>
        /// <param name="userIdentifier">User identifier guid</param>
        /// <param name="cookieExpiry">Optional expiry date for the cookie (for 'Remember me')</param>
        /// <param name="fallbackRedirectUrl">Url to redirect to if none in the querystring</param>
        /// <returns>Nancy response with redirect.</returns>
        public static Response UserLoggedInRedirectResponse(NancyContext context, Guid userIdentifier, DateTime? cookieExpiry = null, string fallbackRedirectUrl = "/")
        {
            var redirectUrl = fallbackRedirectUrl;

            var response = context.GetRedirect(redirectUrl);
            var authenticationCookie = BuildCookie(userIdentifier, cookieExpiry, currentConfiguration);
            response.AddCookie(authenticationCookie);

            return response;
        }
开发者ID:ross2411,项目名称:Ideastrike,代码行数:19,代码来源:FormsAuthentication.cs


注:本文中的Nancy.NancyContext.GetRedirect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。