相关疑难解决方法(0)

如何在jQuery Ajax调用之后管理重定向请求

我正在使用$.post()Ajax调用servlet,然后使用生成的HTML片段替换div用户当前页面中的元素.但是,如果会话超时,服务器会发送重定向指令以将用户发送到登录页面.在这种情况下,jQuery正在用div登录页面的内容替换元素,迫使用户的目光确实见证了罕见的场景.

如何使用jQuery 1.2.6从Ajax调用管理重定向指令?

javascript ajax jquery redirect

1319
推荐指数
26
解决办法
84万
查看次数

从ASP.NET MVC控制器重定向到外部URI

我正在尝试从操作方法重定向到外部URL但无法使其工作.有人可以解释我的错误吗?

public void ID(string id)
    {
        string url = string.Empty;
        switch (id)
        {
            case "DB2FCB11-579F-4DA2-A68C-A6495B9BAAB5":

                url = "http://www.somesite.com";
                break;
        }
        Response.Redirect(url, true);
    }
Run Code Online (Sandbox Code Playgroud)

谢谢,克里斯

url asp.net-mvc redirect

163
推荐指数
2
解决办法
18万
查看次数

从OnActionExecuting重定向到外部URL?

我需要从OnActionExecuting方法重定向到外部网址(例如“ www.google.com”)。现在我正在使用这样的东西:

public override void OnActionExecuting(ActionExecutingContext filterContext)
{
    if (!HttpContext.Current.User.Identity.IsAuthenticated)
    {
        var redirectUrl = "www.google.com";

        try
        {
            var isAjaxRequest = filterContext.HttpContext.Request.IsAjaxRequest();

            if (isAjaxRequest)
            {
                filterContext.HttpContext.Response.StatusCode = SessionController.CustomHttpRedirect;
                filterContext.HttpContext.Response.StatusDescription = redirectUrl;

                filterContext.Result = new JsonResult
                {
                    Data = new { Redirect = redirectUrl },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                };
            }
            else
            {
                filterContext.Result = new RedirectResult(redirectUrl, true);

            }

                return;
            }
            else
            {
                throw new LoggedOutException();
            }
        }
        catch
        {
            throw new LoggedOutException();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

问题在于它没有将我重定向到“ www.google.com”,而是将其重定向到“ http:// localhost:1234 / www.google.com ”(我在本地尝试)。有什么办法解决这个问题?谢谢

asp.net-mvc redirect url-redirection

5
推荐指数
2
解决办法
6131
查看次数

标签 统计

redirect ×3

asp.net-mvc ×2

ajax ×1

javascript ×1

jquery ×1

url ×1

url-redirection ×1