Posts

Test WebService using Postman

Image
1. get token 2. call a method without authen and no parameter input: 3. call a method with an authen token and parameter input: [Authorize]         [HttpPost]         [Route("api/job/saveAddTextJob")]         public HttpResponseMessage SaveAddTextJob([FromBody]MessageModel model)         {  ..... } 4. Call API with File Upload and Job_No:

ASP Net API pass parameter frombody

Image
The action method: 1. Parameter as string public HttpResponseMessage AddText(string jobNo,[FromBody] string text)  {  .... } test action: 2. Parameter as Custom Object public class AddScheduleNote     {         public string JobNo { get; set; }         public string ScheduleNote { get; set; }     }  ................... public HttpResponseMessage UpdateScheduleNote([FromBody] AddScheduleNote note)         {             try             {                 JobSchedule job = db.JobSchedules.Where(r => r.Job_No.Equals(note.JobNo, StringComparison.OrdinalIgnoreCase)).SingleOrDefault();                 if (job == null)                 {                 ...

Update database in Entity Frameword Code first

1. create model (class for table) public class Customer     {         [Key]         public string CustCode { get; set; }         public string Name { get; set; }         public string Address1 { get; set; }   } 2. create DB context:  public class AMWinDBContext: DbContext     {         public AMWinDBContext(): base("AMWinDBContext")         {        }         protected override void OnModelCreating(DbModelBuilder modelBuilder)         {             modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();         }         public virtual DbSet<Customer> Customers { get; set; }         public virtual DbSet<Employee> Employees { get; set; } ...

Redirect HTTP/HTTPS IIS

Image
Setting up an HTTP/HTTPS redirect in IIS Once the SSL certificate is  installed , your site still remains accessible via a regular insecure HTTP connection. To connect securely, visitors must specify the https:// prefix manually when entering your site’s address in their browsers. In order to force a secure connection on your website, it is necessary to set up a certain HTTP/HTTPS redirection rule. This way, anyone who enters your site using a link like “yourdomain.com” will be redirected to “https://yourdomain.com” or “https://www.yourdomain.com” (depending on your choice) making the traffic encrypted between the server and the client side. Below are steps to setup a IIS HTTPS redirect: Download and install  the “URL Rewrite” module. Open the “IIS Manager” console and select the website you would like to apply the redirection to in the left-side menu: Double-click on the “URL Rewrite” icon. Click “Add Rule(s)” in the right-side menu. Select “Blank Rule” in the ...

Allow ASPNET access folder in server machine

To avoid "Access to the path "...." is denied". We need to allow full access to ASPNET Right click on your folder on your server or local machine and give full permissions to IIS_IUSRS

Bootstrap Icons common to use

<link rel='stylesheet' href='https://use.fontawesome.com/releases/v5.7.0/css/all.css' integrity='sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ' crossorigin='anonymous'> <i class='far fa-save'></i> <i class='fas fa-list' style='color:#111E6C;'></i> <i class='fas fa-edit' style='color:#111E6C;'></i> <span class="glyphicon glyphicon-trash" style='color:#111E6C;'></span> <span class="glyphicon glyphicon-option-horizontal" style='color:#111E6C;'></span> <span class="glyphicon glyphicon-expand"></span>

Make DataGridView full screen when screen resize

Option 1: Anchoring: Top, Bottom, Left, Right Option 2: Set the property of your DataGridView: Anchor : Top , Left AutoSizeColumn : Fill Dock : Fill