ASP.Net MVC:禁止重定向到默认页面

时间:2017-05-05 12:25:56

标签: c# asp.net asp.net-mvc-4 forms-authentication

如果web api返回200响应并且收到的消息是

,有一种方法可以禁止重定向到默认页面
<html><head><title>Object moved</title></head><body><h2>Object moved to <a href="/default.aspx">here</a>.</h2></body></html>{"success":true,"message":""}

我们已经实现了一种弹出登录表单的机制,而不是在会话过期时重定向到“登录”页面。会话正确刷新 但是调用返回“对象移动到这里......”并刷新页面。

登录验证是标准的Web表单验证。

Web Api

[System.Web.Http.AllowAnonymous]
[ValidateAntiForgeryToken]
public dynamic RefreshSession(LoginModel model)
   {
    Refresh session implementation
    .........
   }
returns 200 and "Object moved to here ..."

角度通话

 return $http({
                    method: "POST",
                    url: service.Urls.RefreshSession,
                    headers: { 'Content-Type': "application/json" },
                    transformResponse: angular.identity,
                    data: data
                })
                .then(function(response) {
                    return response.data;
                });

我们使用了:context.Response.SuppressFormsAuthenticationRedirect = true 但是没有用。

0 个答案:

没有答案
相关问题