ASP.NET窗体身份验证不重定向 [英] ASP.NET Forms Authentication without Redirect

查看:103
本文介绍了ASP.NET窗体身份验证不重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的 ASP.Net的形式认证,但不希望在禁区被访问重定向到一个登录页面的默认行为。相反,我想引用当前页面上登录一个JavaScript JQuery的对话框,$ P $加载背后pventing的内容。

I am using ASP.Net's forms authentication, but do not want the default behavior of redirecting to a login page when a restricted area is accessed. Instead I would like to invoke a javascript JQuery dialog for the login on the current page, preventing the content behind from loading.

我唯一的问题是,默认情况下窗体身份验证要重定向。

有一个处理程序,我可以钩到,或其他一些选项为 prevent重定向

Is there a handler that I can hook into, or some other option to prevent the redirect?

推荐答案

在除了Dewfy:

以下内容添加到你的web.config:

Add the following to your web.config:

<system.web.extensions>
    <scripting>
      <webServices>
        <authenticationService enabled="true" />    
      </webServices>
    </scripting>
  </system.web.extensions>

您现在可以从JavaScript调用一样认证服务:

You can now call the authentication service from JavaScript like:

 Sys.Services.AuthenticationService.login("username",
    "password", false, null, null, loginCompleted, loginFailed, "");

 function loginCompleted()
 {
     var loginSuccessful = Sys.Services.AuthenticationService.get_isLoggedIn();
     if(loginSuccessful) /* do stuff */
 }

 function loginFailed(result, userContext, method)
 {
     alert('Exception ' + result.get_message());
 }

这篇关于ASP.NET窗体身份验证不重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆