Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

asp.net core webapi works on my local machine but does not work on remote ubuntu server

$
0
0

Hi I need help with asp.net core webapi. please see highlighted code snippet. The highlighted code seem to work fine on my local development machine but does not work on remote ubuntu production server. Please could somebody tell me what is the problem.

        [HttpPost("~/Makwada/Token/Authenticate/{username}/{password}")]
        public IActionResult Authenticate(string username, string password)
        {
            string remote = _accessor.HttpContext.Connection.RemoteIpAddress.ToString();
            var login = Authenticated(username, password);               

            if (login == true)
            {
                return new ObjectResult(GenerateToken(username));
            }
            else
            {
                return Unauthorized();
              
            }

         }

       public bool Authenticated(string username, string password)
        {
            bool result = false;
            string sql = "SELECT Password FROM   account WHERE UserName = @UserName ;";
            using (IDbConnection dbConnection = Connection)
            {
                try
                {
                    dbConnection.Open();
                    DynamicParameters param = new DynamicParameters();
                    param.Add("@UserName", username);
                    string text = Convert.ToString(RuntimeHelpers.GetObjectValue(dbConnection.QuerySingleOrDefaultAsync<string>                          (sql, param, commandType: CommandType.Text).Result));
                    string right = Crypto.CalculateMD5Hash(password);
                    result = (Operators.CompareString(text, right, false) == 0);

                }
                catch (Exception ex)
                {
                    var err = ex.Message;
                   // p.LogError(ex);

                }
                finally
                {

                }
            
                return result;
           }

        }


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>