本文整理汇总了C#中System.Web.HttpContext.Param方法的典型用法代码示例。如果您正苦于以下问题:C# HttpContext.Param方法的具体用法?C# HttpContext.Param怎么用?C# HttpContext.Param使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpContext
的用法示例。
在下文中一共展示了HttpContext.Param方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例2: ProcessRequest
public void ProcessRequest(HttpContext context)
{
string resultStr = GetDefaultSiteResponse();
try
{
var operation = context.Param<SiteOperation>(SiteParameters.OPERATION);
switch (operation)
{
case SiteOperation.CreateUser:
CreateUser(context);
break;
default:
throw new ArgumentOutOfRangeException("Operation");
}
}
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;
}
resultStr = JSONHelper.Serialize(ExceptionHelper.Handle(umse, exceptionCode, message, log));
}
catch (Exception e)
{
resultStr = JSONHelper.Serialize(ExceptionHelper.Handle(e, log));
}
finally
{
context.Response.ContentType = MediaTypeNames.Text.Plain;
context.Response.Write(resultStr);
}
}
示例3: 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);
}
}
示例4: ProcessRequest
public void ProcessRequest(HttpContext context)
{
string result = null;
try
{
string loginToken = context.Param(SiteParameters.LOGIN_TOKEN);
var lt = JSONHelper.Deserialize<LoginToken>(loginToken);
VerifySession(lt);
List<Item> allProducts = CustomerManagementService.GetAllProducts();
result = JSONHelper.Serialize<List<Item>>(allProducts);
}
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);
}
}
示例5: ProcessRequest
public void ProcessRequest(HttpContext context)
{
string result = string.Empty;
try
{
LoginToken lt = JSONHelper.Deserialize<LoginToken>(context.Param(SiteParameters.LOGIN_TOKEN));
SessionUtil.Logout(lt);
result = JSONHelper.Serialize("You have been logged out");
}
catch (Exception e)
{
result = JSONHelper.Serialize(ExceptionHelper.Handle(e, "Could not find session", log));
}
finally
{
context.Response.ContentType = MediaTypeNames.Text.Plain;
context.Response.Write(result);
}
}
示例6: CreateUser
private void CreateUser(HttpContext context)
{
string username = context.Param(SiteParameters.USER_NAME);
string email = context.Param(SiteParameters.USER_EMAIL);
string password = context.Param(SiteParameters.PASSWORD);
string appKeyStr = context.Param(SiteParameters.APP_KEY);
var appKey = new AppKey(appKeyStr);
UserManagementService.CreateUser(username, email, password, appKey);
}
示例7: GetOperation
private Operation GetOperation(HttpContext context)
{
string op = context.Param(SiteParameters.OPERATION);
if (Enum.IsDefined(typeof(Operation), op))
return (Operation)Enum.Parse(typeof(Operation), op);
return Operation.Unknown;
}
示例8: Confirm
private SiteResponse Confirm(HttpContext context)
{
var paymentType = context.Param<PaymentProcessorType>(SiteParameters.PAYMENT_TYPE);
var processor = PaymentProcessorFactory.Create(paymentType);
var transaction = processor.Confirm(context);
var balance = CreditCustomerAccount(transaction);
return new SiteResponse
{
response = "New balance: " + balance,
status = SiteResponse.Status.Success,
syncKey = "aSyncKey"
};
}
示例9: Cancel
private SiteResponse Cancel(HttpContext context)
{
var paymentType = context.Param<PaymentProcessorType>(SiteParameters.PAYMENT_TYPE);
var processor = PaymentProcessorFactory.Create(paymentType);
processor.Cancel(context);
return new SiteResponse
{
response = "Success",
status = SiteResponse.Status.Success,
syncKey = "aSyncKey"
};
}
示例10: Buy
private SiteResponse Buy(HttpContext context)
{
string loginToken = context.Param(SiteParameters.LOGIN_TOKEN);
var paymentType = context.Param<PaymentProcessorType>(SiteParameters.PAYMENT_TYPE);
string productId = context.Param(SiteParameters.PRODUCT_ID);
var lt = JSONHelper.Deserialize<LoginToken>(loginToken);
VerifySession(lt);
var processor = PaymentProcessorFactory.Create(paymentType);
string customerId = GetCustomerId(lt).ToString();
decimal paymentAmount = GetPaymentAmount(productId);
var uri = processor.Buy(customerId, productId, paymentAmount);
var response = new SiteResponse()
{
response = uri,
status = SiteResponse.Status.Success,
syncKey = "aSyncKey"
};
return response;
}
示例11: ProcessRequest
public void ProcessRequest(HttpContext context)
{
string result = null;
try
{
string emailAsString = context.Param(SiteParameters.EMAIL);
MailAddress email = new MailAddress(emailAsString);
string username = context.Param(SiteParameters.USER_NAME);
string password = context.Param(SiteParameters.PASSWORD);
var currentSite = new StringBuilder(context.Request.Url.GetLeftPart(UriPartial.Authority));
// fail fast if either the username or email already exist in the system.
if (SessionUtil.IsUsernameTaken(username))
{
string usernameTakenResponseMessage = "The username " + username + " already exists in this system.";
throw new ApplicationException(usernameTakenResponseMessage);
}
if (SessionUtil.IsEmailTaken(emailAsString))
{
string emailTakenResponseMessage = "The e-mail " + emailAsString + " already exists in this system.";
throw new ApplicationException(emailTakenResponseMessage);
}
for (int i = 0; i < context.Request.Url.Segments.Length - 1; i++)
currentSite.Append(context.Request.Url.Segments[i]);
currentSite.Append("Activate.aspx");
Uri callbackLink = new Uri(currentSite.ToString());
UserManagementService.SignUp(email, username, password, callbackLink);
var response = new SiteResponse()
{
response = "Please check email for activation link.",
status = SiteResponse.Status.Success,
syncKey = "aSyncKey"
};
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);
}
}
示例12: ProcessRequest
public void ProcessRequest(HttpContext context)
{
string result = null;
try
{
SiteResponse response;
var lt = JSONHelper.Deserialize<LoginToken>(context.Param(SiteParameters.LOGIN_TOKEN));
UserManagementService.ValidateLoginToken(lt);
var user = UserManagementService.FindUserWithLoginToken(lt);
var customer = CustomerManagementService.FindCustomerWithUserId(user.Id);
response = new SiteResponse
{
response = new GetCustomerResponse
{
customer = customer,
username = user.AliasName
},
status = SiteResponse.Status.Success,
syncKey = "are we using this?"
};
result = JSONHelper.Serialize<SiteResponse>(response, new[] { typeof(GetCustomerResponse) });
}
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);
}
}
示例13: ChangePassword
private SiteResponse ChangePassword(HttpContext context)
{
string username = context.Param(SiteParameters.USER_NAME);
string oldPwd = context.Param(SiteParameters.PASSWORD);
string newPwd = context.Param(SiteParameters.NEW_PASSWORD);
var lt = JSONHelper.Deserialize<LoginToken>(context.Param(SiteParameters.LOGIN_TOKEN));
if (!UserManagementService.ValidateLoginToken(lt))
throw new ArgumentException("logintoken");
UserManagementService.ChangeUserPassword(username, oldPwd, newPwd);
if (log.IsInfoEnabled)
log.Info("PasswordChange status: success");
return new SiteResponse()
{
response = "Password has been changed.",
status = SiteResponse.Status.Success,
syncKey = "aSyncKey"
};
}
示例14: _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"
};
}
示例15: ProcessRequest
public void ProcessRequest(HttpContext context)
{
string result = null;
try
{
SiteResponse response;
string username = context.Param(SiteParameters.USER_NAME);
string email = context.Param(SiteParameters.EMAIL);
string password = context.Param(SiteParameters.PASSWORD);
var appKey = new AppKey(context.Param(SiteParameters.APP_KEY));
var user = UserManagementService.CreateUser(username, email, password, appKey);
response = new SiteResponse
{
response = user,
status = SiteResponse.Status.Success,
syncKey = "are we using this?"
};
result = JSONHelper.Serialize<SiteResponse>(response, new []{typeof(User)});
}
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);
}
}