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


C# HttpResponse.Redirect方法代码示例

本文整理汇总了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("~/");
     }
 }
开发者ID:Tandysony,项目名称:DemoSite.Mvc,代码行数:8,代码来源:Login.aspx.cs

示例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 = "";
        }
开发者ID:ghostnguyen,项目名称:daccf960-44f9-4f95-91c4-b1aba37effe1,代码行数:58,代码来源:RedBloodSystemBLL.cs

示例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);
         }
     }
 }
开发者ID:SanderArts,项目名称:BandMetro,代码行数:15,代码来源:General.cs

示例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);
            }
        }
开发者ID:hiroakit,项目名称:blog,代码行数:33,代码来源:Global.asax.cs

示例5: RedirectUrl

        public static void RedirectUrl(HttpResponse response)
        {
            var url = PortalContext.RootContext.URL;
            JCUtilities.ResolveUrl(url);

            response.Redirect(url, false);
        }
开发者ID:Erls-Corporation,项目名称:BCProxyLoginPortlet,代码行数:7,代码来源:BCProxyLogin.cs

示例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");
 }
开发者ID:ridhi29,项目名称:dataminingproject,代码行数:7,代码来源:SelectDatasetDynamic.cs

示例7: WriteResponse

		/// <summary>
		/// 写入到http回应
		/// </summary>
		/// <param name="response"></param>
		public void WriteResponse(HttpResponse response) {
			if (Permanent) {
				response.RedirectPermanent(Url);
			} else {
				response.Redirect(Url);
			}
		}
开发者ID:daywrite,项目名称:ZKWeb,代码行数:11,代码来源:RedirectResult.cs

示例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");
     }
 }
开发者ID:kissmettprj,项目名称:col,代码行数:17,代码来源:PersonBLL.cs

示例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"]);
 }
开发者ID:kassemshehady,项目名称:Uber-CMS,代码行数:17,代码来源:Base.cs

示例10: Redirect

 private static void Redirect(HttpResponse response, string url, bool permanent)
 {
     if (permanent) {
         response.RedirectPermanent(url, true);
     }
     else {
         response.Redirect(url, false);
     }
 }
开发者ID:jonnycundall,项目名称:RouteMagic,代码行数:9,代码来源:RedirectHttpHandler.cs

示例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");
     }
 }
开发者ID:Acasa-Dan,项目名称:MyQuizWebApp,代码行数:9,代码来源:LoginService.cs

示例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;
        }
开发者ID:meze,项目名称:betteamsbattle,代码行数:57,代码来源:LanguageService.cs

示例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);
        }
开发者ID:rsdgjb,项目名称:GRP_PERFICIENT,代码行数:14,代码来源:RedirectHelper.cs

示例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");
     }
 }
开发者ID:kissmettprj,项目名称:col,代码行数:10,代码来源:CorpAdminBLL.cs

示例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}");
        }
开发者ID:SymbioSweden,项目名称:BestPracticeDotNet,代码行数:10,代码来源:Global.asax.cs


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