I want to display a modal window after the user logs in ASP.NET

1

When the credentials are correct I have no problem and show the modal window. but if the credentials are incorrect, it also appears. I am handling it with an Onclick event of the login button, and to know if there is an authentication I use Request.IsAuthenticated. The idea with that was if it is false I have hidden the modal and if it is true to show it. But it does not work for me at the time of an invalid login.

this is the code that I have of the modal:

<div class="modal" id="myModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
    <div class="modal-content">
        <div class="modal-header">
            <h5 class="modal-title">Bienvenido</h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
            </button>
        </div>
        <div class="modal-body">
            <p align="center">Bienvenido al sistema CRISEB.</p>
            <p align="center">Precione Aceptar para continuar.</p>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-primary" data-dismiss="modal">Aceptar</button>

        </div>
    </div>
</div>

then the code of the button where the javascript function calls:

<div class="form-group">
                <div class="col-md-offset-2 col-md-10">
                    <input type="submit" value="Iniciar sesión" class="btn btn-default" onclick="MostrarMensajeDeBienvenida()"/>
                </div>
            </div>

and this is the JS code:

<script>

function MostrarMensajeDeBienvenida() {


    if ('@Request.IsAuthenticated'== false) {

        $('#myModal').modal('hide')

    } else {

        $('#myModal').modal('show')

    }

}

I think the problem I have is when the post is done when the session starts and the page is loading, when there is an incorrect session start

    
asked by Alvaro Morales 11.09.2018 в 02:51
source

1 answer

0

The '@Request.IsAuthenticated' is returning true or false, but as a text string instead of boolean, so the condition should be:

if ('@Request.IsAuthenticated'== 'False') {...}

Attention to the capital 'F'.

    
answered by 09.10.2018 в 16:21