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


C# HttpContext.HasParam方法代码示例

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


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

示例1: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            string result = null;

            try
            {
                string username;

                if (context.HasParam(SiteParameters.USER_NAME))
                    username = context.Param(SiteParameters.USER_NAME);
                else
                {
                    string email = context.Param(SiteParameters.EMAIL);
                    var user = UserManagementService.FindUserWithEmail(email);
                    username = user.AliasName;
                }

                string password = context.Param(SiteParameters.PASSWORD);

                var lt = SessionUtil.Login(username, password);
                result = JSONHelper.Serialize<LoginToken>(lt);
            }
            catch (UserManagementServiceException umse)
            {
                ExceptionHelper.Code exceptionCode = ExceptionHelper.Code.UnexpectedException;
                string message = umse.Message;

                switch (umse.Code)
                {
                    case UserManagementServiceException.ErrorCode.UnexpectedError:
                        break;
                    case UserManagementServiceException.ErrorCode.ObjectNotFound:
                        exceptionCode = ExceptionHelper.Code.InvalidLogin;
                        break;
                    case UserManagementServiceException.ErrorCode.InvalidOperationOnResource:
                        exceptionCode = ExceptionHelper.Code.InvalidOperation;
                        break;
                    case UserManagementServiceException.ErrorCode.AccessDenied:
                        exceptionCode = ExceptionHelper.Code.AccessDenied;
                        break;
                    case UserManagementServiceException.ErrorCode.CouldNotConnectToDatabase:
                        message = "Could not connect to the database. " + message;
                        break;
                    default:
                        message = "Unknown ErrorCode: " + umse.Code + ". Message: " + message;
                        break;
                }

                result = JSONHelper.Serialize(ExceptionHelper.Handle(umse, exceptionCode, message, log));
            }
            catch (Exception e)
            {
                result = JSONHelper.Serialize(ExceptionHelper.Handle(e, log));
            }
            finally
            {
                context.Response.ContentType = MediaTypeNames.Text.Plain;
                context.Response.Write(result);
            }
        }
开发者ID:esegura,项目名称:VirtualCurrency,代码行数:60,代码来源:Login.ashx.cs

示例2: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            string result = null;

            try
            {
                SiteResponse response;

                if (context.HasParam(SiteParameters.OPERATION)
                        && context.Param<SiteOperation>(SiteParameters.OPERATION) == SiteOperation.ChangePassword)
                    response = ChangePassword(context);
                else
                    response = _ResetPassword(context);

                result = JSONHelper.Serialize<SiteResponse>(response);
            }
            catch (UserManagementServiceException umse)
            {
                ExceptionHelper.Code exceptionCode = ExceptionHelper.Code.UnexpectedException;
                string message = umse.Message;

                switch (umse.Code)
                {
                    case UserManagementServiceException.ErrorCode.UnexpectedError:
                        break;
                    case UserManagementServiceException.ErrorCode.ObjectNotFound:
                        exceptionCode = ExceptionHelper.Code.InvalidLogin;
                        break;
                    case UserManagementServiceException.ErrorCode.InvalidOperationOnResource:
                        exceptionCode = ExceptionHelper.Code.InvalidOperation;
                        break;
                    case UserManagementServiceException.ErrorCode.AccessDenied:
                        exceptionCode = ExceptionHelper.Code.AccessDenied;
                        break;
                    case UserManagementServiceException.ErrorCode.CouldNotConnectToDatabase:
                        message = "Could not connect to the database. " + message;
                        break;
                    default:
                        message = "Unknown ErrorCode: " + umse.Code + ". Message: " + message;
                        break;
                }

                result = JSONHelper.Serialize(ExceptionHelper.Handle(umse, exceptionCode, message, log));
            }
            catch (Exception e)
            {
                result = JSONHelper.Serialize(ExceptionHelper.Handle(e, log));
            }
            finally
            {
                context.Response.ContentType = MediaTypeNames.Text.Plain;
                context.Response.Write(result);
            }
        }
开发者ID:esegura,项目名称:VirtualCurrency,代码行数:54,代码来源:ResetPassword.ashx.cs

示例3: _ResetPassword

        private static SiteResponse _ResetPassword(HttpContext context)
        {
            string email = string.Empty;
            string username = string.Empty;

            if (context.HasParam(SiteParameters.EMAIL))
                email = context.Param(SiteParameters.EMAIL);

            if (context.HasParam(SiteParameters.USER_NAME))
                username = context.Param(SiteParameters.USER_NAME);

            SessionUtil.ResetPassword(username, email);

            if (log.IsInfoEnabled)
                log.Info("PasswordReset status: success");

            return new SiteResponse()
            {
                response = "Please check email for new password.",
                status = SiteResponse.Status.Success,
                syncKey = "aSyncKey"
            };
        }
开发者ID:esegura,项目名称:VirtualCurrency,代码行数:23,代码来源:GetCustomer.ashx.cs


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