Click here to Skip to main content
15,302,656 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello ! Today I just noticed that after I launched my application and headed to the log in section it worked good, but after I entered the correct username and the password I got a big error. That happens also if I just put some random passwords or usernames. Can someone help me ?

System.Net.WebException: 'The remote server returned an error: (403) Forbidden.'

The code that provides the error:

C#
private void signinBtn1_Click(object sender, EventArgs e)
        {
            //ResponseInformation.loginresponse.Failure is a boolean, which will will be true if login failed
            ResponseInformation.loginresponse = ClientFunctions.Login(userTB.Text, passTB.Text, ProgramInformation.ProgramId);
            //Here we set password so we can use them throughout the application
            ResponseInformation.Password = passTB.Text;
            if (ResponseInformation.loginresponse.Failure)
            {

                //Message will be the reason for failed login
                MessageBox.Show(ResponseInformation.loginresponse.Message, SafeGuardTitle.safeguardtitle);
            }
            else
            {

                //Message will be "Successfully Logged In"
                Properties.Settings.Default.Username = ResponseInformation.loginresponse.UserName;
                Properties.Settings.Default.Password = ResponseInformation.Password;
                Properties.Settings.Default.Save();

                //this.Alert("Login Successful! Redirecting. . .", AlertForm.enmType.Success);
                MessageBox.Show($"Welcome{ResponseInformation.loginresponse.UserName}!\n" + (DateTime.Now.Date), SafeGuardTitle.safeguardtitle, MessageBoxButtons.OK, MessageBoxIcon.Information);


                this.Hide();
                MainForm frmMain = new MainForm();
                frmMain.ShowDialog();
                this.Close();

            }
        }


What I have tried:

I am trying to change some variables that are set. I don't think they will work but I can try
Posted
Updated 20-Mar-21 23:51pm
v2
Comments
Richard MacCutchan 21-Mar-21 5:50am
   
You need to check the server code. That is where the error response is raised.

1 solution

I'd suggest to read this: HTTP 403 - Wikipedia[^]

The devil is in the details ;)
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900