本文整理汇总了C#中HttpResponse.Redirect方法的典型用法代码示例。如果您正苦于以下问题:C# HttpResponse.Redirect方法的具体用法?C# HttpResponse.Redirect怎么用?C# HttpResponse.Redirect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpResponse
的用法示例。
在下文中一共展示了HttpResponse.Redirect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: login
public void login(HttpRequest request, HttpResponse response, System.Web.SessionState.HttpSessionState session)
{
if(String.IsNullOrEmpty(serviceLogoutUrl))
throw new Exception("ERROR: service Logout Url not defined");
if(String.IsNullOrEmpty(centralizedSPUrl))
throw new Exception("ERROR: centralized SP Url not defined");
if(String.IsNullOrEmpty(request.Params["xmlAttrib"])){
string serviceUrl = request.RawUrl;
string auth = "<auth><serviceURL>"+serviceUrl+"</serviceURL><logoutURL>"+serviceLogoutUrl+"</logoutURL>";
if(!String.IsNullOrEmpty(authenticationMethodList)){
auth += "<authnContextList>";
foreach(string authenticationMethod in authenticationMethodList)
auth += "<authnContext>"+authenticationMethod+"</authnContext>";
auth += "</authnContextList>";
}
auth += "</auth>";
string authB64 = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(auth));
response.Redirect(centralizedSPUrl+"/PoA?xmlAuth="+System.Web.HttpUtility.UrlEncode(authB64));
} else {
string userAttributes = System.Text.Encoding.ASCII.GetString(Convert.FromBase64String(request.Params["xmlAttrib"]));
session["userAttributes"] = userAttributes;
if(!String.IsNullOrEmpty(request.Params["ReturnUrl"]))
response.Redirect(request.Params["ReturnUrl"]);
}
}
示例2: RedirectToReturnUrl
public static void RedirectToReturnUrl(string returnUrl, HttpResponse response)
{
if (!String.IsNullOrEmpty(returnUrl) && IsLocalUrl(returnUrl))
{
response.Redirect(returnUrl);
}
else
{
response.Redirect("~/");
}
}
示例3: RedirecionaPaginaInicial
public static void RedirecionaPaginaInicial(int MinutosDuracaoSessao,
HttpResponse Response, string ID)
{
FormsAuthentication.Initialize();
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1, ID,
DateTime.Now,
DateTime.Now.AddMinutes(MinutosDuracaoSessao),
true,
FormsAuthentication.FormsCookiePath);
string hash = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash);
Response.Cookies.Add(cookie);
Response.Redirect(PaginasAplicacao.GetPaginaInicial());
}
示例4: pageInstall
/// <summary>
/// Runs the installation script, responsible for initially setting up the CMS and any base plugins.
/// </summary>
/// <param name="request"></param>
/// <param name="response"></param>
/// <param name="content"></param>
public static void pageInstall(ref UberCMS.Misc.PageElements pageElements, HttpRequest request, HttpResponse response, ref StringBuilder content)
{
#if INSTALLED
response.Redirect(pageElements["BASE_URL"]);
#else
// Create connector object
Connector conn = dbSettings.create();
try
{
// Run installer Scripts
string s = "";
MethodInfo m;
foreach (Type clas in Assembly.GetAssembly(typeof(UberCMS.Installer.InstallScript)).GetTypes())
if (clas.Namespace == "UberCMS.Installer")
{
m = clas.GetMethod("install");
m.Invoke(null, new object[] { conn });
}
else s += clas.FullName + "<br />";
// Successful - write success to web.config
UberCMS.Misc.Plugins.preprocessorDirective_Add("INSTALLED");
// Redirect to finish page
response.Redirect(pageElements["BASE_URL"]);
}
catch (Exception ex)
{
content.Append(
templates[TEMPLATES_KEY]["install_error"]
.Replace("%MESSAGE_PRIMARY%", HttpUtility.HtmlEncode(ex.Message))
.Replace("%STACK_TRACE_PRIMARY%", HttpUtility.HtmlEncode(ex.StackTrace))
.Replace("%MESSAGE_BASE%", HttpUtility.HtmlEncode(ex.GetBaseException().Message))
.Replace("%STACK_TRACE_BASE%", HttpUtility.HtmlEncode(ex.GetBaseException().StackTrace))
);
pageElements["TITLE"] = "Installation Failed";
}
// Dispose connector
conn.Disconnect();
#endif
}
示例5: EnforcePermissions_RequireAny
public static void EnforcePermissions_RequireAny(HttpSessionState session, HttpResponse response, bool requireStakeholder, bool requireMasterAdmin, bool requireAdmin, bool requirePrincipal, bool requireProvider, bool requireStaff)
{
UserView userView = UserView.GetInstance();
if (requireStakeholder && userView.IsStakeholder)
return;
if (requireMasterAdmin && userView.IsMasterAdmin)
return;
if (requireAdmin && userView.IsAdmin)
return;
if (requirePrincipal && userView.IsPrincipal)
return;
if (requireProvider && userView.IsProvider)
return;
if (requireStaff && userView.IsStaff)
return;
response.Redirect(PagePermissions.UnauthorisedAccessPageForward());
}
示例6: logout
public void logout(bool invalidateSession, HttpRequest request, HttpResponse response, System.Web.SessionState.HttpSessionState session)
{
if(!String.IsNullOrEmpty(request.Params["remoteLogout"])){
session["userAttributes"] = null;
if(invalidateSession) {
System.Web.Security.FormsAuthentication.SignOut();
session.Abandon();
session.Clear();
}
} else {
if(!String.IsNullOrEmpty(request.Params["ReturnUrl"]))
response.Redirect(request.Params["ReturnUrl"]);
}
}
示例7: LogoutV2
public static void LogoutV2(System.Web.SessionState.HttpSessionState session, HttpResponse response, HttpRequest request, bool includeForwardUrl = true)
{
if (session["StaffID"] != null)
UserLoginDB.UpdateSetAllSessionsLoggedOut(Convert.ToInt32(session["StaffID"]), -1);
if (session["PatientID"] != null)
UserLoginDB.UpdateSetAllSessionsLoggedOut(-1, Convert.ToInt32(session["PatientID"]));
Utilities.UnsetSessionVariables();
//System.Web.Security.FormsAuthentication.SignOut();
if (!HttpContext.Current.Request.Url.LocalPath.Contains("/Account/LoginV2.aspx"))
{
if (includeForwardUrl)
response.Redirect("~/Account/LoginV2.aspx" + "?from_url=" + request.RawUrl);
else
response.Redirect("~/Account/LoginV2.aspx");
}
}
示例8: pageUsers
public static void pageUsers(Connector conn, ref Misc.PageElements pageElements, HttpRequest request, HttpResponse response)
{
if (request.QueryString["2"] != null)
{
// Editing a user
string error = null;
bool updatedAccount = false;
// Set SQL injection protection flag (to disable flag)
pageElements.setFlag(Plugins.BasicSiteAuth.FLAG_PASSWORD_ACCESSED);
// Grab the user's info, bans and available user groups
Result user = conn.Query_Read("SELECT * FROM bsa_users WHERE userid='" + Utils.Escape(request.QueryString["2"]) + "'");
if (user.Rows.Count != 1) return;
Result bans = conn.Query_Read("SELECT b.*, u.username FROM bsa_user_bans AS b LEFT OUTER JOIN bsa_users AS u ON u.userid=b.banner_userid ORDER BY datetime DESC");
Result userGroups = conn.Query_Read("SELECT groupid, title FROM bsa_user_groups ORDER BY access_login ASC, access_changeaccount ASC, access_media_create ASC, access_media_edit ASC, access_media_delete ASC, access_media_publish ASC, access_admin ASC, title ASC");
string dban = request.QueryString["dban"];
// Check for deleting a ban
if (dban != null)
{
conn.Query_Execute("DELETE FROM bsa_user_bans WHERE banid='" + Utils.Escape(dban) + "'");
conn.Disconnect();
response.Redirect(pageElements["ADMIN_URL"] + "/" + user[0]["userid"], true);
}
// Check for postback of banning the user
string ban = request.QueryString["ban"];
string banCustom = request.QueryString["ban_custom"];
string banReason = request.QueryString["ban_reason"];
if (ban != null || banCustom != null)
{
int banAmount = 0;
if (ban != null)
{
if (ban.Equals("Permanent"))
banAmount = 0;
else if (ban.Equals("1 Month"))
banAmount = 2628000;
else if (ban.Equals("1 Week"))
banAmount = 604800;
else if (ban.Equals("3 Days"))
banAmount = 259200;
else if (ban.Equals("1 Day"))
banAmount = 86400;
else
error = "Invalid ban period!";
}
else
{
if (banCustom != null && !int.TryParse(banCustom, out banAmount))
error = "Invalid ban period, not numeric!";
else if (banAmount < 0)
error = "Ban period cannot be less than zero!";
}
if(error == null)
{
// Get the time at which the user will be unbanned
DateTime dt = DateTime.Now.AddSeconds(-banAmount);
// Insert the record
conn.Query_Execute("INSERT INTO bsa_user_bans (userid, reason, unban_date, datetime, banner_userid) VALUES('" + Utils.Escape(user[0]["userid"]) + "', '" + Utils.Escape(banReason) + "', " + (banAmount == 0 ? "NULL" : "'" + Utils.Escape(dt.ToString("yyyy-MM-dd HH:mm:ss")) + "'") + ", NOW(), '" + Utils.Escape(HttpContext.Current.User.Identity.Name) + "')");
// Refresh the page
conn.Disconnect();
response.Redirect(pageElements["ADMIN_URL"] + "/" + user[0]["userid"], true);
}
}
// Check for postback of editing the user
string username = request.Form["username"];
string password = request.Form["password"];
string email = request.Form["email"];
string secretQuestion = request.Form["secret_question"];
string secretAnswer = request.Form["secret_answer"];
string groupid = request.Form["groupid"];
if (username != null && password != null && email != null && secretQuestion != null && secretAnswer != null && groupid != null)
{
if (username.Length < Plugins.BasicSiteAuth.USERNAME_MIN || username.Length > Plugins.BasicSiteAuth.USERNAME_MAX)
error = "Username must be " + Plugins.BasicSiteAuth.USERNAME_MIN + " to " + Plugins.BasicSiteAuth.USERNAME_MAX + " characters in length!";
else if ((error = Plugins.BasicSiteAuth.validUsernameChars(username)) != null)
;
else if (!Plugins.BasicSiteAuth.validEmail(email))
error = "Invalid e-mail!";
else if (password.Length != 0 && (password.Length < Plugins.BasicSiteAuth.PASSWORD_MIN || password.Length > Plugins.BasicSiteAuth.PASSWORD_MAX))
error = "Password must be " + Plugins.BasicSiteAuth.PASSWORD_MIN + " to " + Plugins.BasicSiteAuth.PASSWORD_MAX + " characters in length!";
else if (secretQuestion.Length < Plugins.BasicSiteAuth.SECRET_QUESTION_MIN || secretQuestion.Length > Plugins.BasicSiteAuth.SECRET_QUESTION_MAX)
error = "Secret question must be " + Plugins.BasicSiteAuth.SECRET_QUESTION_MIN + " to " + Plugins.BasicSiteAuth.SECRET_QUESTION_MAX + " characters in length!";
else if (secretAnswer.Length < Plugins.BasicSiteAuth.SECRET_ANSWER_MIN || secretAnswer.Length > Plugins.BasicSiteAuth.SECRET_ANSWER_MAX)
error = "Secret answer must be " + Plugins.BasicSiteAuth.SECRET_ANSWER_MIN + " to " + Plugins.BasicSiteAuth.SECRET_ANSWER_MAX + " characters in length!";
else
{
// Ensure the groupid is valid
bool groupFound = false;
foreach (ResultRow group in userGroups) if (group["groupid"] == groupid) groupFound = true;
if (!groupFound)
error = "Invalid group!";
else
{
// Attempt to update the user's details
try
{
conn.Query_Execute("UPDATE bsa_users SET username='" + Utils.Escape(username) + "', email='" + Utils.Escape(email) + "', " + (password.Length > 0 ? "password='" + Utils.Escape(Plugins.BasicSiteAuth.generateHash(password, Plugins.BasicSiteAuth.salt1, Plugins.BasicSiteAuth.salt2)) + "', " : string.Empty) + "secret_question='" + Utils.Escape(secretQuestion) + "', secret_answer='" + Utils.Escape(secretAnswer) + "', groupid='" + Utils.Escape(groupid) + "' WHERE userid='" + Utils.Escape(user[0]["userid"]) + "'");
updatedAccount = true;
}
catch (DuplicateEntryException ex)
{
//.........这里部分代码省略.........
示例9: toLoginNoAuthPage
private void toLoginNoAuthPage(HttpResponse httpResponse)
{
httpResponse.Redirect(MANAGE_NOAUTH_PATH, false);
return;
}
示例10: Find
//isSOD: isStartOfDate
//public static void ScanExp(bool isSOD)
//{
//if (!isSOD || !LogBLL.IsLog(Task.TaskX.ScanExp))
//{
// RedBloodDataContext db = new RedBloodDataContext();
// List<Pack.StatusX> statusList = new List<Pack.StatusX> { Pack.StatusX.Product };
// IQueryable<Pack> rs = db.Packs.Where(r => statusList.Contains(r.Status) && r.ExpirationDate < DateTime.Now.Date);
// foreach (Pack r in rs)
// {
// PackStatusHistory h = PackBLL.Update(db, r, Pack.StatusX.Expired, RedBloodSystem.SODActor, "");
// if (h != null) db.PackStatusHistories.InsertOnSubmit(h);
// }
// db.SubmitChanges();
// LogBLL.Add(Task.TaskX.ScanExp);
//}
//}
//isSOD: isStartOfDate
//public static void CloseOrder(bool isSOD)
//{
// //if (!isSOD || !LogBLL.IsLog(Task.TaskX.CloseOrder))
// //{
// // RedBloodDataContext db = new RedBloodDataContext();
// // OrderBLL.CloseOrder(db);
// // db.SubmitChanges();
// // LogBLL.Add(Task.TaskX.CloseOrder);
// //}
//}
//isSOD: isStartOfDate
//public static void LockTestResult()
//{
//if (!isSOD || !LogBLL.IsLog(Task.TaskX.LockEnterTestResult))
//{
// RedBloodDataContext db = new RedBloodDataContext();
// PackBLL.LockEnterTestResult();
// db.SubmitChanges();
// LogBLL.Add(Task.TaskX.LockEnterTestResult);
//}
//}
/// <summary>
/// if true, count remaining packs directly in store
/// else count by sum up the remaining of previous date and total transaction in day
/// </summary>
/// <param name="date"></param>
/// <returns></returns>
//static bool IsCountDirectly(DateTime date)
//{
// RedBloodDataContext db = new RedBloodDataContext();
// bool isCountDirectly = false;
// //new system, no data
// if (db.PackTransactions.Count() == 0)
// isCountDirectly = true;
// else
// {
// if (lastPackTransactionDate == null) throw new Exception("");
// else
// {
// GetLastTransactionDate();
// //All pack transactions were in the previous of the date.
// if (lastPackTransactionDate.Value.Date <= date.Date)
// isCountDirectly = true;
// }
// }
// return isCountDirectly;
//}
public static void Find(HttpResponse Response, TextBox txtCode)
{
if (txtCode == null) return;
string key = txtCode.Text.Trim();
if (key.Length == 0) return;
string pattern = @"\d+";
Regex regx = new Regex(pattern);
if (BarcodeBLL.IsValidPeopleCode(key))
{
People r = PeopleBLL.GetByCode(key);
if (r != null)
{
Response.Redirect(RedBloodSystem.Url4PeopleDetail + "key=" + r.ID.ToString());
}
}
else if (BarcodeBLL.IsValidDINCode(key))
{
Response.Redirect(RedBloodSystem.Url4PackDetail + "key=" + BarcodeBLL.ParseDIN(key));
}
else if (BarcodeBLL.IsValidCampaignCode(key))
{
Campaign r = CampaignBLL.Get(BarcodeBLL.ParseCampaignID(key));
if (r != null)
{
Response.Redirect(RedBloodSystem.Url4CampaignDetail + "key=" + r.ID.ToString());
}
}
else if (BarcodeBLL.IsValidOrderCode(key))
{
Order r = OrderBLL.Get(BarcodeBLL.ParseOrderID(key));
if (r != null)
//.........这里部分代码省略.........
示例11: CheckSessionTimeout
public bool CheckSessionTimeout(Hashtable State, HttpResponse Response, string URL)
{
if (State == null || State.Count <= 2)
{
if (State != null)
State["PreviousError"] = "Your session has timed out.";
Response.Redirect(URL, false);
return true;
}
return false;
}
示例12: ProcessMainExceptions
public void ProcessMainExceptions(Hashtable State, HttpResponse Response, Exception ex)
{
if (State != null)
{
string error = ex.Message + "- " + ex.StackTrace;
try
{
UpdateSessionLog(State, "error: " + error, "Util");
}
catch { }//if there is an error in the DB keep going
LogError(State, ex);
Logout(State);
}
Response.Redirect("Default.aspx", false);
}
示例13: Process
/// <summary>
/// Process the incoming request.
/// </summary>
/// <param name="request">incoming HTTP request</param>
/// <param name="response">outgoing HTTP response</param>
/// <returns>true if response should be sent to the browser directly (no other rules or modules will be processed).</returns>
/// <remarks>
/// returning true means that no modules will get the request. Returning true is typically being done
/// for redirects.
/// </remarks>
public virtual bool Process(HttpRequest request, HttpResponse response)
{
if (request.Uri.AbsolutePath == FromUrl)
{
if (!ShouldRedirect)
{
request.Uri = new Uri(request.Uri, ToUrl);
return false;
}
response.Redirect(ToUrl);
return true;
}
return false;
}
示例14: protectPage
public void protectPage(HttpRequest request, HttpResponse response, System.Web.SessionState.HttpSessionState session)
{
if(String.IsNullOrEmpty(session["userAttributes"])){
string url = serviceLoginUrl+"?ReturnUrl="+System.Web.HttpUtility.UrlEncode(request.RawUrl);
response.Redirect(url);
}
}
示例15: toLoginPage
private void toLoginPage(HttpResponse httpResponse)
{
httpResponse.Redirect(MANAGE_ERROR, false);
return;
}