Parser Error - An error occurred during the parsing of a resource required to service this request

0

I am developing a web system in ASP.NET using Visual Studio 2017 , I use a WebService in the part of Backend to make queries to the database, the problem is that when publishing the project in the server throws me the following error in the file ASMX which is the one that does reference to the code of WebService :

This error occurs only on the server when calling any method of the WebService , testing the project with IIS Express in Visual Studio It does not give problem.

Does anyone know how to solve this problem?

I searched online but the solutions they give are unclear and they are not very well explained, besides they do not have very good Most comments.

The error is given to me when I start session, here the method:

[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
public void LoginingUser()
{
    if (HttpContext.Current.Session["nombre"] == null && HttpContext.Current.Session["logueado"] == null && HttpContext.Current.Session["Rol"] == null)
    {
        try
        {
            SqlConnection sqlConn = Conectar();
            sqlConn.Open();
            SqlCommand sqlComm = null;

            //HttpContext.Current.Session["token"] = GetToken();
            SToken = GetToken();

            SqlConnection LogConn = Conectar();
            SqlCommand LogComm = null;

            String LogQuerie = "EXEC mpLogLogin @Id, @Nick, @Token, @Ip, @PcName, @Start, @End, @LastEvent, @MessageError, @IpError, @PcNameError";

            String existsUser = "EXEC mpExistsUser @user,@pass";
            String loginUserString = "EXEC mpUserLogin @user,@pass";

            sqlComm = new SqlCommand(existsUser, sqlConn);
            sqlComm.Parameters.Add("@user", SqlDbType.VarChar).Value = HttpContext.Current.Request["user"];
            sqlComm.Parameters.Add("@pass", SqlDbType.VarChar).Value = HttpContext.Current.Request["password"];
            SqlDataReader dataReader = sqlComm.ExecuteReader();

            HttpContext.Current.Session["UserName"] = HttpContext.Current.Request["user"];

            //if (dataReader["NumReg"] == "1")
            dataReader.Read();
            if (dataReader["NumReg"].ToString() == "1")
            {
                dataReader.Close();
                String key = "EXEC mpAutoLogin @user";

                sqlComm = new SqlCommand(key, sqlConn);
                sqlComm.Parameters.Add("@user", SqlDbType.VarChar).Value = HttpContext.Current.Request["user"];
                dataReader = sqlComm.ExecuteReader();
                dataReader.Read();

                if (dataReader["logueado"].ToString() == "0" || VerifyTime() >= 2)
                {
                    dataReader.Close();
                    sqlComm = new SqlCommand(loginUserString, sqlConn);
                    sqlComm.Parameters.Add("@user", SqlDbType.VarChar).Value = HttpContext.Current.Request["user"];
                    sqlComm.Parameters.Add("@pass", SqlDbType.VarChar).Value = HttpContext.Current.Request["password"];
                    dataReader = sqlComm.ExecuteReader();
                    dataReader.Read();

                    HttpContext.Current.Session["logueado"] = "true";
                    HttpContext.Current.Session["nick"] = dataReader["Nick"];
                    HttpContext.Current.Session["nombre"] = dataReader["Nombre"];
                    HttpContext.Current.Session["correo"] = dataReader["Correo"];
                    HttpContext.Current.Session["telefono"] = dataReader["Telefono"];
                    HttpContext.Current.Session["rol"] = dataReader["Rol"].ToString();
                    HttpContext.Current.Session["compania"] = dataReader["compania"];
                    HttpContext.Current.Session["token"] = SToken;

                    dataReader.Close();

                    String Ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
                    String LIp = HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"];

                    sqlComm = new SqlCommand("EXEC mpUserLoger @nick, @inicio, @ip, @lip", sqlConn);
                    sqlComm.Parameters.Add("@nick", SqlDbType.VarChar).Value = Session["nick"];
                    sqlComm.Parameters.Add("@inicio", SqlDbType.DateTime).Value = DateTime.Now;
                    sqlComm.Parameters.Add("@ip", SqlDbType.VarChar).Value = Ip;
                    sqlComm.Parameters.Add("@lip", SqlDbType.VarChar).Value = LIp;

                    dataReader = sqlComm.ExecuteReader();
                    dataReader.Read();
                    dataReader.Close();

                    LogLogin("");

                    /*sqlComm = new SqlCommand("EXEC logLogin @Idlog, @Bname, @Token, @Ip, @PcName, @DtStart, NULL, @DtLastEvent, @MessageError, @IpError, @PcName");
                    sqlComm.Parameters.Add("@IdLog", SqlDbType.VarChar).Value = LastIdLog("login");
                    sqlComm.Parameters.Add("@Bname", SqlDbType.VarChar).Value = ;
                    sqlComm.Parameters.Add("@Token", SqlDbType.VarChar).Value = HttpContext.Current.Session["token"].ToString();
                    sqlComm.Parameters.Add("@Ip", SqlDbType.VarChar).Value = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
                    sqlComm.Parameters.Add("@PcName", SqlDbType.VarChar).Value = HttpContext.Current.Request.ServerVariables["REMOTE_USER"];
                    sqlComm.Parameters.Add("@DtStart", SqlDbType.DateTime).Value = DateTime.Now;

                    sqlComm.Parameters.Add("@DtLastEvent", SqlDbType.DateTime).Value = ;
                    sqlComm.Parameters.Add("@MessageError", SqlDbType.VarChar).Value = ;
                    sqlComm.Parameters.Add("@IpError", SqlDbType.VarChar).Value = ;
                    sqlComm.Parameters.Add("@PcNameError", SqlDbType.VarChar).Value = ;*/
                }
                else
                {
                    HttpContext.Current.Response.Redirect("../LogError.aspx");
                    LogLogin("Inicio de sesion multiple");
                }
            }
            switch (HttpContext.Current.Session["rol"].ToString())
            {
                case "1":
                    //HttpContext.Current.Response.Redirect("Logistica.aspx");
                    HttpContext.Current.Response.Redirect("../Default1.aspx");
                    break;
                case "2":
                    HttpContext.Current.Response.Redirect("../Registrar.aspx");
                    break;
                case "3":
                    //HttpContext.Current.Response.Redirect("Logistica.aspx");
                    HttpContext.Current.Response.Redirect("../Default1.aspx");
                    break;
                default:
                    HttpContext.Current.Response.Redirect("../Login.aspx");
                    break;
            }
        }
        catch (Exception ex)
        {
            HttpContext.Current.Response.Write("ERROR DE INICIO" + ex);
        }
    }
}

And I call it as a% normal% co, sending the data of my form with a login button.

    
asked by HatsuNET 05.09.2018 в 16:09
source

0 answers