ASP.NET forms authentication without redirection

I use ASP.Net forms authentication , but I donโ€™t want the default behavior to be redirected to the login page when accessing the restricted area. Instead, I would like to call the jQuery jQuery dialog to enter the current page, which will prevent the content from loading.

My only problem is that by default forms authentication requires redirection.

Is there a handler with which I can connect, or is there any other option to prevent redirection ?

+2
source share
3 answers

In addition to Dewfy:

Add the following to your web.config:

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

Now you can call the authentication service from JavaScript, for example:

 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());
 }
+3
source

Yes, if you are dealing with jQuery consideration of the ability to use standard ASP.Net ajax-oriented Sys.Services.AuthenticationService.

+2
source

, LoginView. , . - ASP.NET, .

0

Source: https://habr.com/ru/post/1758788/


All Articles