Skip to main content

Posts

Showing posts from January, 2019

Configure DNS to use an external mail server in Windows Server

External mail server can be used in the hosting server by configuring Mail Exchange ( MX ) Record. The Domain Name System(DNS) has several types of resource records that full fill the name to ip address translation(Directly or indirectly). One of the widely used record is MX Record.        An MX record should return the fully qualified domain name of an email server and its preference value . MX Record can be configured by following the step below. 1. Open DNS Manager 2. Add A Record for your mail          (eg: mail.domain.com with the ip address of another server) 3. Add  MX Record and set FQDN  to the name assigned in A Record           (i.e mail.domain.com)      Preference number can have any value between 0 to 65535 and lower number sets for higher            priority. After completing this step, The mail server is pointed to the ip addres provided in the A record for the specific domain.

SqlException: Login failed for user 'IIS APPPOOL\

This issue is related with the permission for application pool to connect with the sql. We can create login user with the name as specified in the exception  IIS APPPOOL\<name> and grant permission to the database. We can create new login user by opening the SSMS(Sql server management studio) navigate to Security>Login  Then Add the user by right clicking Login and selecting new login While creating user Navigate to UserMapping and tick the database for the specific user. This process will create the new user and gran permission to the user. Another Work Around Yet another simple way will be to change the application pool Identity property  To LocalSystem by navigating to the application pool and then advance setting.

Bubble Sort in C-Sharp

Bubble Sort is a simple sorting algorithms that iterates through a list and compares adjacent item and swaps them in the order if they are in the wrong order.  The iteration is completed after the  items bubble to there specific position and the list is sorted ascending or descending. Bubble sort is simple but too slow and impractical in most of the cases. Figure : Algorithm: for all elements in Array if Array [ i ] > Array [ i + 1 ] swap ( Array [ i ], Array [ i + 1 ]) end if end for return Array CODE :

Reading and Writing to a file text file in C#

Lets start by taking the below  code as an example:    private void WriteToAFile(){             string data = "hi ! what's up";             string path = "data.txt";             if (!File.Exists(path))             {                 File.Create(path);             }             using (StreamWriter writer = new StreamWriter(path, append: true))             {                 writer.WriteLine(data);             } } Writing to a text file can be achieved by using StreamWriter class . To use this class we need to use System.IO namespace. if we are writing to a file then exception might occur if the file doesn't exists. So firstly we need to check if the File Exists. If it doesn't exist we can create a file in the path specified. Here in example I haven't provided the fully qualified path like  "C:\Users\Mypc\project\Sample" absolute path  but rather used relative path by providing only the file name. Th

Classes and Objects In C#

Class  is a collection of fields, properties and methods. It depicts real life entities and is a fundamental concept in Object Oriented Programming.  A class is a user-defined blueprint  from which objects are created . A class is a user defined data type of  reference type. Lets take a example of a Car . It has different attributes like color,maximum speed,no of gears on with a built in audio player  and so on. public class Car {     private string  _color; //a variable and a field with data type string     // a variable and  a property       public string Color       {         get         {             return _color;         }         set         {             _color= value;         } public void  PlayAudio() { //implementation logic } } Declaration Of Class:  <access specifier><keyword:class> <class name: Car> public class car if access identifier is not explicitly mentioned a class has internal access identifier a

Installing Windows Service

What is a windows Service ?  Windows service is a long running process that runs as a background process in windows OS.           We create windows service when we need to perform tasks without the user interaction. Like regular application windows services lacks UI for user interaction. We can install windows service by navigating to installutil.exe file that resides in Microsoft.Net Folder inside Windows folder. For for .net version 4 the file path is  C:\Windows\Microsoft.NET\Framework\v4.0.30319  we can install the service by running the following command in CommandLine  opening it as an Administrator. "C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe" "E:\servicename.exe"   See the following command run for installing the merotrackerlistener in the system.      After running the command windows service is installed in the system.