All posts by kalaksh

C# convert string to date

Hey there! If you’re working with C#, I’d be happy to help you out with converting a string to a date. All you need is the DateTime.Parse or DateTime.ParseExact method from the System namespace.  It’s super easy! Using DateTime.Parse: If the date string format is recognized by the DateTime.Parse method, it can be directly used….

Read More

Get IP Address in Asp.net Core API

To get the client’s IP address in an ASP.NET Core API controller, Private IP Address var privateIPAddress = HttpContext.Connection.RemoteIpAddress?.ToString(); Public IP Address string url = “https//atulbaba.com”;var request = System.Net.WebRequest.Create(url);var getResponse = request.GetResponse();var reader = new System.IO.StreamReader(getResponse.GetResponseStream());var response = reader.ReadToEnd().Trim(); var responseArray = response.Split(new Char[] { ‘:’, ‘<‘ },StringSplitOptions.RemoveEmptyEntries); var publicIPAddresss = responseArray[6]; using Microsoft.AspNetCore.Mvc; using…

Read More