Domanda

I am using asp.net and i am trying to login from the fancy box. I have code sample like this :

          function (LoginResponse) {
                      $.each(LoginResponse, function () {
                          if (this["IsLogin"] == "true") {
                              window.location.reload(true);
                              window.location.href = "Account/MyProfile.aspx";
                          }
                          else {
                              jAlert('Warning!', 'Invalid login Credintials', 'Please enter valid Username and Password..', 'yellow');
                          }
                          clear_form_elements('#UserLoginSection'); //Clears the element of the form
                      });
                  }
                    );

Some time it goes well with this address "Account/MyProfile.aspx" But some time The Address wrong and in the address bar something like this come again and again "Account/Account/MyProfile.aspx" There should not be Double Account meaning "Account/MyProfile.aspx" should be there. and I have tried to remove Account in the javascript function above But some time it works well but some time it does not. What i have to do please help me.

È stato utile?

Soluzione

If you want to land the user after login on "MyProfile.aspx" then use window.location.href or if you want them on same page then only use location.reload(true). No need to use both at same time.

Altri suggerimenti

Setting location.href to a different URL should already reload the page. Use either reload or location.href, not both.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top