简体   繁体   中英

Config Window authentication show login prompt after close all and reopen browser ASP.NET MVC

I am using window authentication using Active directory. But it can not reopen window login prompt after authenticated. Although I closed all browser before reopen.

My current config:

<authentication mode="Windows" />
    <authorization>
      <deny users="?"/>
    </authorization>`
</authentication>
<membership defaultProvider="ADMembership">
    <providers>
        <add name="ADMembership"
             type="System.Web.Security.ActiveDirectoryMembershipProvider,
                   System.Web, Version=2.0.0.0, Culture=neutral,
                   PublicToken=b03f5f7f11d50a3a"
             connectionStringName="ADConn"
             connectionUsername="domain/user"
             connectionPassword="pwd" />
    </providers>
</membership>
<connectionStrings>  
    <add name="ADConn" 
         connectionString="LDAP://YourConnection" />
</connectionStrings>
  • Enabled Windows authentication
  • Disabled anonymous authentication

I want the window login prompt open when you closed all browser instant and reopen browser follow:

  1. access link to my site by browser
  2. window login prompt show, fill user name and password
  3. authenticated and can process site
  4. close all browser
  5. reopen browser with access link
  6. window login prompt should show.

Problem:

Currently step 6 is not happening, the browser still keep the cache authenticated.

Please help if you know the right config.

Thank you.

you could use the javascript in the page in sending a regular post in the background and set up a serverside agent or service that disposes of the sessions if it doesnt receive these regular "heartbeat" signals, by using javascript postback onto the page's unload()


its need two steps

1)Detect if the browser closed as below code

 window.onbeforeunload = function (event) {
var message = 'Important: Please click on \'Save\' button to leave this page.';
if (typeof event == 'undefined') {
    event = window.event;
}
if (event) {
    event.returnValue = message;
}
return message; $(function () {
$("a").not('#lnkLogOut').click(function () {
    window.onbeforeunload = null;
});
$(".btn").click(function () {
    window.onbeforeunload = null;});});

2)Delete the cached authentications

 document.execCommand("ClearAuthenticationCache");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM