本文整理汇总了C#中System.Web.HttpResponse.Redirect方法的典型用法代码示例。如果您正苦于以下问题:C# HttpResponse.Redirect方法的具体用法?C# HttpResponse.Redirect怎么用?C# HttpResponse.Redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpResponse
的用法示例。
在下文中一共展示了HttpResponse.Redirect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RedirectToReturnUrl
public static void RedirectToReturnUrl(string returnUrl, HttpResponse response) {
if (!String.IsNullOrEmpty(returnUrl) && IsLocalUrl(returnUrl)) {
response.Redirect(returnUrl);
}
else {
response.Redirect("~/");
}
}
示例2: Find
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.Url4DINDetail + "key=" + BarcodeBLL.ParseDIN(key));
}
//else if (BarcodeBLL.IsValidDINCode_NoIdChar(key))
//{
// Response.Redirect(RedBloodSystem.Url4DINDetail + "key=" + BarcodeBLL.ParseDIN_NoIdChar(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)
{
Response.Redirect(RedBloodSystem.Url4Order4CR + "key=" + r.ID.ToString());
}
}
else if (key.Length > 3 && key.Substring(0, 3) == "/n:")
{
Response.Redirect(RedBloodSystem.Url4FindPeople + "key=" + key.Substring(3).Trim());
}
else if (regx.IsMatch(key) && key.Length >= BarcodeBLL.CMNDLength.ToInt())
{
People r = PeopleBLL.GetByCMND(key);
if (r != null)
{
Response.Redirect(RedBloodSystem.Url4PeopleDetail + "key=" + r.ID.ToString());
}
}
txtCode.Text = "";
}
示例3: checkloggedin
public static void checkloggedin(HttpResponse myresponse, HttpSessionState mysession, string to_page)
{
var to_url = "login.aspx";
if (to_page != "") to_url += "?page=" + to_page;
if (mysession["fullname"] == null)
{
myresponse.Redirect(to_url, true);
} else
{
if (mysession["fullname"].ToString().Trim() == "")
{
myresponse.Redirect(to_url, true);
}
}
}
示例4: RedirectToNotFoundPage
// エラーページへ転送します。可能ならばAzureのテーブルにロギングします
// なお、転送先のエラーページはweb.configのcustomErrorsセクションで定義しません
private void RedirectToNotFoundPage(Exception exception, HttpResponse response, Boolean isLogging)
{
if (exception == null)
{
return;
}
string path = ErrorPagePath;
if (!this.Request.Path.Contains("ja-JP"))
{
path = path.Replace("ja-JP", "en-US");
response.Redirect(path, false);
}
if (exception.GetType() == typeof(HttpRequestValidationException))
{
if (isLogging)
{
AzureLog.WriteToTable(exception);
}
response.Redirect(path, false);
}
else
{
if (isLogging)
{
AzureLog.WriteToTable(exception);
}
response.Redirect(path, false);
}
}
示例5: RedirectUrl
public static void RedirectUrl(HttpResponse response)
{
var url = PortalContext.RootContext.URL;
JCUtilities.ResolveUrl(url);
response.Redirect(url, false);
}
示例6: start
public void start(Analysis parent, HttpResponse response, System.Web.SessionState.HttpSessionState session)
{
caller = parent;
Debug.WriteLine("SelectData step of " + caller.getDisplayName() + " started");
session["stepid"] = 1;
response.Redirect("~/Default.aspx");
}
示例7: WriteResponse
/// <summary>
/// 写入到http回应
/// </summary>
/// <param name="response"></param>
public void WriteResponse(HttpResponse response) {
if (Permanent) {
response.RedirectPermanent(Url);
} else {
response.Redirect(Url);
}
}
示例8: CheckSession
public static void CheckSession(System.Web.SessionState.HttpSessionState session, HttpRequest request, HttpResponse response)
{
if (session["person.id"] == null)
{
string url = request.Url.PathAndQuery;
//session["lasturl"] = "~" + url;
session["lasturl"] = url;
response.Redirect("~/person/account/login.aspx");
}
int passworduserchanged = Functions.ParseInt(session["person.passworduserchanged"],0);
if (0 == passworduserchanged)
{
string url = request.Url.PathAndQuery;
if (!url.Contains("/person/account/changepassword.aspx"))
response.Redirect("~/person/account/changepassword.aspx?needuserchange=1");
}
}
示例9: handleRequest
public static void handleRequest(string pluginid, Connector conn, ref Misc.PageElements pageElements, HttpRequest request, HttpResponse response)
{
// Toggle cookie-control
HttpCookie cookie = request.Cookies["cookie-control"];
if (cookie != null)
{
cookie.Expires = DateTime.Now.AddDays(-1);
response.Cookies.Add(cookie);
}
else
response.Cookies.Add(new HttpCookie("cookie-control", "1"));
// Redirect to the origin or homepage
if (request.UrlReferrer != null)
response.Redirect(request.UrlReferrer.AbsoluteUri);
else
response.Redirect(pageElements["URL"]);
}
示例10: Redirect
private static void Redirect(HttpResponse response, string url, bool permanent)
{
if (permanent) {
response.RedirectPermanent(url, true);
}
else {
response.Redirect(url, false);
}
}
示例11: LoginUser
public void LoginUser(HttpRequest request, HttpResponse response, string username, string password)
{
var result = _UserRepository.LogInUser(username, password);
if (result > 0)
{
AddCookie(request, response, result.ToString());
response.Redirect("HomeWebForm.aspx");
}
}
示例12: ProccessLanguageForRequest
public Language ProccessLanguageForRequest(User user, HttpRequest request, HttpResponse response)
{
Language language;
string pathCountryCode;
UrlCountryCodeHelper.GetPathCountryCodeParts(request.Url.GetComponents(UriComponents.Path, UriFormat.Unescaped), out pathCountryCode);
if (LanguageMappingHelper.CountryCodeIsSupported(pathCountryCode))
{
language = LanguageMappingHelper.GetLanguageByCountryCode(pathCountryCode);
var userLanguage = GetLanguage(user, request);
if (!userLanguage.HasValue || userLanguage.Value != language)
ChangeLanguage(user, language, response);
}
else
{
if (user != null)
{
var userLanguage = GetAuthenticatedUserLanguage(user);
if (userLanguage.HasValue)
language = userLanguage.Value;
else
{
language = _ipToLanguageConverter.GetLanguage(request.UserHostAddress);
ChangeAuthenticatedUserLanguage(user, language);
}
}
else
{
var cookieLanguage = GetNonAuthenticatedUserLanguage(request);
if (cookieLanguage.HasValue)
language = cookieLanguage.Value;
else
{
language = _ipToLanguageConverter.GetLanguage(request.UserHostAddress);
ChangeNonAuthenticatedUserLanguage(language, response);
}
}
}
var correctPathCountryCode = LanguageMappingHelper.GetCountryCodeByLanguage(language);
if (pathCountryCode != correctPathCountryCode)
{
var newUrl = UrlCountryCodeHelper.ChangeUrlCountryCodePart(request.Url, language);
response.Redirect(newUrl);
}
HttpContext.Current.Items[FrontendConstants.LanguageKey] = language;
var cultureInfo = LanguageMappingHelper.GetDefaultCultureInfo(language);
Thread.CurrentThread.CurrentUICulture = cultureInfo;
Thread.CurrentThread.CurrentCulture = cultureInfo;
return language;
}
示例13: ReloadRedirect
/// <summary>
/// Reloads the redirect.
/// </summary>
/// <param name="reportId">The report id.</param>
/// <param name="response">The response.</param>
public static void ReloadRedirect(int reportId, HttpResponse response)
{
var url = string.Format(
"{0}?ReportId={1}&IsCopy=True",
HttpContext.Current.Request.Url.AbsolutePath,
reportId);
response.Redirect(url);
}
示例14: CheckSession
public static void CheckSession(System.Web.SessionState.HttpSessionState session, HttpRequest request, HttpResponse response)
{
if (session["corpadmin.id"] == null)
{
string url = request.Url.PathAndQuery;
//session["lasturl"] = "~" + url;
session["lasturl"] = url;
response.Redirect("~/corp/account/login.aspx");
}
}
示例15: EnsureHttps
static void EnsureHttps(HttpRequest req, HttpResponse res)
{
if (req.IsSecureConnection)
return;
if (req.IsLocal && DebugMode)
return;
res.Redirect($"https://{req.Url.Authority}{req.Url.PathAndQuery}");
}