Ejemplo n.º 1
0
        public void FillResponse(HttpResponseBase response, HttpContextBase context)
        {
            var jobName  = context.Request.Params["job"];
            var jobGroup = context.Request.Params["group"];

            _schedulerProvider.Scheduler.ResumeJob(jobName, jobGroup);
            response.Redirect(context.Request.UrlReferrer.OriginalString);
        }
 public static void SessionIsAlive(HttpSessionStateBase Session, HttpResponseBase Response)
 {
     if (Session.Contents.Count == 0)
     {
         Response.Redirect("Timeout.html");
         //Response.Redirect("");
     }
 }
Ejemplo n.º 3
0
 public static void RedirectToUrl(this HttpResponseBase response, string url)
 {
     response.Clear();                       // 这里是关键,清除在返回前已经设置好的标头信息,这样后面的跳转才不会报错
     response.BufferOutput = true;           // 设置输出缓冲
     if (!response.IsRequestBeingRedirected) // 在跳转之前做判断,防止重复
     {
         response.Redirect(url, true);
     }
 }
Ejemplo n.º 4
0
        public static void RedirectWithQueryString(this HttpResponseBase response, string url)
        {
            var server  = HttpContext.Current.Server;
            var request = HttpContext.Current.Request;

            var qs = server.UrlEncode(request.QueryString.ToString());

            response.Redirect(url + "?" + server.UrlDecode(qs));
        }
Ejemplo n.º 5
0
 public JsonResult UpdateCustomerServicePlan(CustomerServicePlanDetailModel input)
 {
     if (admin.Role.Equals(SystemParam.ROLE_TECHNICAL_STAFF))
     {
         HttpResponseBase response = Response;
         response.Redirect("/ServicePlanManage/Index");
     }
     input.UserID = admin.Id;
     return(Json(customerServicePlan.UpdateCustomerServicePlan(input), JsonRequestBehavior.AllowGet));
 }
Ejemplo n.º 6
0
    public static void ExcluirFeed(HttpResponseBase response, HttpRequestBase request)
    {
        Dao.inicializa();
        Feed e = new Feed();

        e.ID = int.Parse(request["inputID"].ToString());
        Dao.deleteFeed(e);

        response.Redirect("~/Views/Menus/Feed.cshtml");
    }
Ejemplo n.º 7
0
        public ActionResult Index()
        {
            if (!admin.Role.Equals(SystemParam.ROLE_ADMIN))
            {
                HttpResponseBase response = Response;
                response.Redirect("/Home/Index");
            }

            return(View());
        }
Ejemplo n.º 8
0
        public void Redirect(string schemaName, string recordId)
        {
            Request.Headers.Set("Redirect-Terrasoft", "true");
            HttpResponseBase response = GetResponse();

            response.AddHeader("Connection", "close");
            string url = GetUrl(schemaName, recordId);

            response.Redirect(url, false);
        }
Ejemplo n.º 9
0
    public static void ExcluirImagem(HttpResponseBase response, HttpRequestBase request)
    {
        Dao.inicializa();
        Imagem e = new Imagem();

        e.ID = int.Parse(request["inputID"].ToString());
        Dao.deleteImagem(e);

        response.Redirect("~/Views/Menus/Imagem.cshtml");
    }
Ejemplo n.º 10
0
    public static void AtualizarRegistro(HttpResponseBase response, HttpRequestBase request)
    {
        Dao.inicializa();
        Registro e = new Registro();

        e.LicencaAtiva = request["inputLicenca"];
        e.Cnpj         = request["Cnpj"];

        Dao.updateRegistro(e);
        response.Redirect("~/Views/Menus/Admin.cshtml");
    }
Ejemplo n.º 11
0
        public override void ExecuteResult(ControllerContext context)
        {
            HttpResponseBase response = context.HttpContext.Response;

            if (String.IsNullOrEmpty(this.userData))
            {
                FormsAuthentication.SetAuthCookie(this.userName, this.persistentCookie);
            }
            else
            {
                FormsAuthenticationTicket ticket =
                    new FormsAuthenticationTicket(1, this.userName,
                                                  DateTime.Now, DateTime.Now.AddMinutes(5),
                                                  this.persistentCookie,
                                                  this.userData,
                                                  FormsAuthentication.FormsCookiePath);
                string encryptedTicket = FormsAuthentication.Encrypt(ticket);

                HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName,
                                                   encryptedTicket);
                cookie.HttpOnly = true;
                cookie.Secure   = FormsAuthentication.RequireSSL;
                cookie.Path     = FormsAuthentication.FormsCookiePath;
                if (FormsAuthentication.CookieDomain != null)
                {
                    cookie.Domain = FormsAuthentication.CookieDomain;
                }

                Logger.Write("Storing user login cookie", "Controller", 10, 0, TraceEventType.Verbose, "Storing cookie in FormsLoginResult.ExecuteResult",
                             new Dictionary <string, object>
                {
                    { "Cookie", cookie },
                    { "UserName", this.userName },
                    { "FormsCookiePath", FormsAuthentication.FormsCookiePath },
                    { "CookieDomain", FormsAuthentication.CookieDomain },
                    { "EncryptedTicket", encryptedTicket }
                }
                             );

                response.Cookies.Add(cookie);
            }

            string redirectUrl = FormsAuthentication.GetRedirectUrl(this.userName, this.persistentCookie);

            Logger.Write("Redirecting login user", "Controller", 10, 0, TraceEventType.Verbose, "URL Redirect in FormsLoginResult.ExecuteResult",
                         new Dictionary <string, object>
            {
                { "RedirectURL", redirectUrl },
                { "UserName", this.userName },
                { "PersistentCookie", this.persistentCookie }
            }
                         );
            response.Redirect(redirectUrl);
        }
Ejemplo n.º 12
0
 public void Connect(string hostUrl)
 {
     if (!IsConnectedToO365)
     {
         HttpCookie spHostUrlCookie = new HttpCookie("SPHostUrl");
         spHostUrlCookie.Value   = hostUrl;
         spHostUrlCookie.Expires = DateTime.Now.AddYears(5);
         _response.Cookies.Add(spHostUrlCookie);
         _response.Redirect(TokenHelper.GetAuthorizationUrl(hostUrl, "Web.Manage"));
     }
 }
Ejemplo n.º 13
0
        public static void BackToPrevPageOrIndex(HttpRequestBase request, HttpResponseBase response)
        {
            Uri    uri = request.UrlReferrer;
            string url = "/Index";

            if (uri != null)
            {
                url = uri.ToString();
            }
            response.Redirect(url);
        }
Ejemplo n.º 14
0
 /// <summary>
 /// 页面跳转
 /// </summary>
 /// <param name="response"></param>
 /// <param name="url"></param>
 public static void Redirect(HttpResponseBase response, string url)
 {
     try
     {
         if (!response.IsRequestBeingRedirected)
         {
             response.Redirect(url, true);
         }
     }
     catch { }
 }
Ejemplo n.º 15
0
    public static void SalvarImagem(HttpResponseBase response, HttpRequestBase request)
    {
        Dao.inicializa();
        Imagem e = new Imagem();

        e.Endereco = request["inputEndereco"];
        e.Largura  = int.Parse(request["inputLargura"].ToString());
        e.Altura   = int.Parse(request["inputAltura"].ToString());
        Dao.setImagem(e);

        response.Redirect("~/Views/Menus/Imagem.cshtml");
    }
Ejemplo n.º 16
0
 public void FillResponse(HttpResponseBase response, HttpContextBase context)
 {
     DoAction(response, context);
     if (context.Request.UrlReferrer != null)
     {
         response.Redirect(context.Request.UrlReferrer.OriginalString);
     }
     else
     {
         response.End();
     }
 }
Ejemplo n.º 17
0
    public static void ValidaUsuario(HttpResponseBase response, HttpRequestBase request, HttpContextBase context)
    {
        Usuario u = new Usuario();

        u.Email = request["email"];
        u.Senha = request["password"];

        bool x = Dao.validarUsuario(u);

        if (x)
        {
            context.Session["user"] = Dao.gerarChaveUsuario();
            context.Session.Timeout = 9999;
            response.Redirect("~/Views/Menus/Admin.cshtml");
        }
        else
        {
            context.Session["user"] = String.Empty;
            response.Redirect("~/Views/Menus/Admin.cshtml");
        }
    }
Ejemplo n.º 18
0
        /// <summary>
        /// OnActionExecuting
        /// </summary>
        /// <param name="filterContext">filter context</param>
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            HttpRequestBase  Request  = filterContext.HttpContext.Request;
            HttpResponseBase Response = filterContext.HttpContext.Response;

            if (!Request.IsSecureConnection && !Request.IsLocal)
            {
                var Builder = new UriBuilder(Request.Url);
                Builder.Scheme = Uri.UriSchemeHttps;
                Response.Redirect(Builder.Uri.ToString());
            }
            base.OnActionExecuting(filterContext);
        }
Ejemplo n.º 19
0
        public static bool HandleRequestLocationException(Exception exception, BlogRequest blogRequest, IInstallationManager installManager, HttpResponseBase response)
        {
            if (blogRequest.RequestLocation != RequestLocation.Installation &&
                blogRequest.RequestLocation != RequestLocation.Upgrade)
            {
                if (installManager.InstallationActionRequired(VersionInfo.CurrentAssemblyVersion, exception))
                {
                    response.Redirect("~/install/default.aspx", true);
                    return(true);
                }
            }

            if (blogRequest.RequestLocation != RequestLocation.SystemMessages)
            {
                if (exception.GetType() == typeof(BlogInactiveException))
                {
                    response.Redirect("~/SystemMessages/BlogNotActive.aspx", true);
                    return(true);
                }
            }
            return(false);
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            HttpRequestBase  req = filterContext.HttpContext.Request;
            HttpResponseBase res = filterContext.HttpContext.Response;

            //Check if we're secure or not and if we're on the local box
            if (!req.IsSecureConnection && !req.IsLocal && Tools.IsAppSettingTrue("RedirectToHttps"))
            {
                string url = req.Url.ToString().ToLower().Replace("http:", "https:");
                res.Redirect(url);
            }
            base.OnActionExecuting(filterContext);
        }
Ejemplo n.º 21
0
    public static void SalvarFeed(HttpResponseBase response, HttpRequestBase request)
    {
        Dao.inicializa();
        Feed e = new Feed();

        e.Ordem      = int.Parse(request["inputOrdem"].ToString());
        e.Noticia    = request["inputNoticia"];
        e.Titulo     = request["inputTitulo"];
        e.Velocidade = int.Parse(request["inputVelocidade"].ToString());
        Dao.setFeed(e);

        response.Redirect("~/Views/Menus/Feed.cshtml");
    }
Ejemplo n.º 22
0
        /// <summary>
        /// </summary>
        /// <param name="httpContext"></param>
        /// <param name="url">The foreign service to redirect to</param>
        /// <param name="proxyTicketUrlParameter">
        ///     The ticket parameter to include in the remote service Url.
        /// </param>
        /// <param name="endResponse">
        ///     Boolean indicating whether or not to short circuit the remaining request
        ///     pipeline events
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// The url or proxyTicketUrlParameter supplied is null
        /// </exception>
        /// <exception cref="ArgumentException">
        /// The url or proxyTicketUrlParametersupplied is empty
        /// </exception>
        public void ProxyRedirect(HttpContextBase httpContext, string url, string proxyTicketUrlParameter, bool endResponse)
        {
            Argument.ThrowIfNullOrEmpty(url, "url", "url parameter cannot be null or empty.");
            Argument.ThrowIfNull(proxyTicketUrlParameter, "proxyTicketUrlParameter", "proxyTicketUrlParameter parameter cannot be null or empty.");

            HttpResponseBase response = httpContext.Response;

            string proxyRedirectUrl = _urlUtil.GetProxyRedirectUrl(url, proxyTicketUrlParameter, (resolvedUrl) => {
                return(GetProxyTicketIdFor(httpContext, resolvedUrl));
            });

            response.Redirect(proxyRedirectUrl, endResponse);
        }
Ejemplo n.º 23
0
        public bool ForceHttps(ActionExecutingContext filterContext)
        {
            HttpRequestBase  req = filterContext.HttpContext.Request;
            HttpResponseBase res = filterContext.HttpContext.Response;

            const int DefaultPort = 80;
            const int SecuredPort = 443;

            //Check if we're secure or not and if we're on the local box
            //if (!req.IsSecureConnection && !req.IsLocal && Maps.UseSecureConnection)

            var  builder  = new UriBuilder(req.Url);
            bool redirect = false;

            if (!req.IsSecureConnection && Maps.UseSecureConnection)
            {
                if (builder.Scheme != Uri.UriSchemeHttps || builder.Port != SecuredPort)
                {
                    builder.Scheme = Uri.UriSchemeHttps;
                    builder.Port   = SecuredPort;

                    redirect = true;
                }
            }

            SqlProduct sqlProduct = Maps.GetCurrentSqlProduct();

            if (Maps.SplitProducts && Maps.ProductsPort.ContainsKey(sqlProduct))
            {
                int port = Maps.ProductsPort[sqlProduct];
                if (builder.Port != port)
                {
                    builder.Port = port;
                    redirect     = true;
                }
            }

            if (redirect)
            {
                string url = builder.Uri.ToString();
                if (req.IsLocal)
                {
                    string appName = Maps.GetCurrentAppName();
                    url = url.Replace("localhost", appName + "." + Maps.Host, false);
                }
                res.Redirect(url);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 24
0
        /* Web网站首页,调用的函数,获取Code后跳转到RedirectUrl【中间可能会(is_base为False)临时跳转到微信授权页】
         * is_base为True时,不显示授权页面,用户感知的是直接进入页面
         * is_base为False时,显示授权页面,用户感知的是先点击授权,然后进入页面 */
        protected void _FirstPage_AuthToGetCode(HttpResponseBase response, bool is_base, string redirect_url)
        {
            redirect_url = HttpUtility.UrlEncode(redirect_url);
            string url = @"https://open.weixin.qq.com/connect/oauth2/authorize" +
                         "?appid=" + _app_id +
                         "&redirect_uri=" + redirect_url +
                         "&response_type=code" +
                         "&scope=" + (is_base ? "snsapi_base" : "snsapi_userinfo") +
                         "&state=123" +
                         "#wechat_redirect";

            response.Redirect(url);
            response.End();
        }
Ejemplo n.º 25
0
    public static void AtualizarEmpresa(HttpResponseBase response, HttpRequestBase request)
    {
        Dao.inicializa();
        Empresa e = new Empresa();

        e.Nome        = request["inputNome"];
        e.Cnpj        = request["Cnpj"];
        e.Endereco    = request["inputEndereco"];
        e.Fone        = request["inputFone"];
        e.Responsavel = request["inputResponsavel"];

        Dao.updateEmpresa(e);
        response.Redirect("~/Views/Menus/Admin.cshtml");
    }
Ejemplo n.º 26
0
        /// <summary>
        /// Logs the user out of the application and attempts to perform a Single Sign
        /// Out against the CAS server.  If the CAS server is configured to support
        /// Single Sign Out, this will prevent users from gateway authenticating
        /// to other services.  The CAS server will attempt to notify any other
        /// applications to revoke the session.  Each of the applications must be
        /// configured to maintain session state on the server.  In the case of
        /// ASP.NET web applications using DotNetCasClient, this requires defining a
        /// serviceTicketManager.  The configuration for other client types (Java,
        /// PHP) varies based on the client implementation.  Consult the Jasig wiki
        /// for more details.
        /// </summary>
        public void SingleSignOut(HttpContextBase httpContext)
        {
            HttpResponseBase response = httpContext.Response;

            // Necessary for ASP.NET MVC Support.
            if (_authenticationService.GetAuthenticatedUser() != null)
            {
                ClearAuthCookie(httpContext);
                string singleSignOutRedirectUrl = _urlUtil.ConstructSingleSignOutRedirectUrl();

                // Leave endResponse as true.  This will throw a handled ThreadAbortException
                // but it is necessary to support SingleSignOut in ASP.NET MVC applications.
                response.Redirect(singleSignOutRedirectUrl, true);
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        ///     When overridden in a derived class, returns route information about the request.
        /// </summary>
        /// <param name = "httpContext">An object that encapsulates information about the HTTP request.</param>
        /// <returns>
        ///     An object that contains the values from the route definition if the route matches the current request, or null if the route does not match the request.
        /// </returns>
        public override RouteData GetRouteData(HttpContextBase httpContext)
        {
            HttpRequestBase  request  = httpContext.Request;
            HttpResponseBase response = httpContext.Response;

            string loginRequest = request.QueryString["ReturnUrl"];

            if (loginRequest != null && loginRequest.ToLowerInvariant().Contains("/content/setup"))
            {
                return(null);
            }

            response.Redirect("/Dxt-Setup/Home/Index");

            return(null);
        }
Ejemplo n.º 28
0
        protected override void HandleUnauthorizedRequest(AuthorizationContext fc)
        {
            HttpResponseBase res = fc.HttpContext.Response;

            if (fc.HttpContext.Request.IsAjaxRequest())
            {
                httpResult _res = new httpResult(4, "请登录");
                res.Write(JsonConvert.SerializeObject(_res));
                res.ContentType = "application/json";
                res.End();
            }
            else
            {
                res.Redirect(cf.LoginUrl, true);
            }
        }
Ejemplo n.º 29
0
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        HttpRequestBase  request  = filterContext.HttpContext.Request;
        HttpResponseBase response = filterContext.HttpContext.Response;

        if (request != null &&
            response != null)
        {
            bool isAuthenticated = request.IsAuthenticated;
            filterContext.Controller.ViewData["IsAuthenticated"] = isAuthenticated;
            if (!isAuthenticated)
            {
                response.Redirect(String.Format("/?ReturnUrl={0}", HttpUtility.UrlEncode(request.Url.ToString())));
            }
        }
    }
Ejemplo n.º 30
0
        public static void RedirectUser(this HttpResponseBase response, string url)
        {
            if (response.IsRequestBeingRedirected)
            {
                return;
            }
            url = Uri.EscapeUriString(url);
            url = ValidateUrl(url);
            response.Redirect(url, false);
            var context = HttpContext.Current;

            if (context != null)
            {
                context.ApplicationInstance.CompleteRequest();
            }
        }
Ejemplo n.º 31
0
 internal static void RedirectToLogin(HttpResponseBase response)
 {
     response.Redirect(GetVirtualPath(LoginVirtualPath));
 }
Ejemplo n.º 32
0
 internal static void RedirectToRegister(HttpResponseBase response)
 {
     response.Redirect(GetVirtualPath(RegisterVirtualPath));
 }
Ejemplo n.º 33
0
 internal static void RedirectToHome(HttpResponseBase response)
 {
     response.Redirect(AdminVirtualPath);
 }