Logging Exceptions In-Depth

Exceptions are safeguards to deal with any unexpected or exceptional situations and logging them helps finding the root cause of issues during runtime. Significance of logging becomes even more critical on production where resources to debug are very scarce. So, to have in-depth information on what gone wrong and where play a very important role …

Get Absolute URL – Web Application

Getting fully qualified absolute path of ASP.NET application is always tricky and problem arises when code moves across various platform. Hard coding the Application Path is no where a good solution here. The URL syntax is: scheme://domain:port/path?query_string#fragment_id Two solutions that you can look for in such scenarios: 1. Add an entry in your web.config file …

Upload Binary data as HTTP POST

Below is the ASP.NET C# implementation of Uploading binary data like images as POST request to target URL: private bool UploadFile(string PostURL) { try { int contentLength = fileUpload.PostedFile.ContentLength; byte[] data = new byte[contentLength]; fileUpload.PostedFile.InputStream.Read(data, 0, contentLength); // Prepare web request… HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(PostURL); webRequest.Method = "POST"; webRequest.ContentType = "multipart/form-data"; webRequest.ContentLength = data.Length; using …