Question

I have written the following code for login:

 Session["IsLogin"] = false;
        System.Configuration.Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
        if (txtPassword.Text.Trim() == string.Empty)
        {
            // Display Error
        }
        else
        {
            string Pwd = config.AppSettings.Settings["PWD"].Value.ToString();
            FormsAuthenticationTicket formAuthTk = FormsAuthentication.Decrypt(Pwd);
            string strDcryptedPwd = formAuthTk.Name.Trim().ToString();
            if (txtPassword.Text.Trim() == strDcryptedPwd)
            {
                Session["IsLogin"] = true;
                Response.Redirect("AnyPage.aspx");
            }
            else
            {
                // Error, Wrong password
            }
        }

Which is running fine while running through Visual studio. But when I published it it is showing the below error:

System.Web.HttpException: Unable to validate data

NOTE:

  1. I publish the application on the same server on which I am developing the site.

  2. I have tried EnableViewStateMAC = false on page level. [Login Page]

What is the reson of this error? Why it is only appears when I have published the site?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top