Categories
Technology

Blazor Performance Optimization: Lazy Loading Guide

Blazor is a powerful framework for building interactive web applications using .NET. As applications grow in size and complexity, performance optimization becomes crucial. One effective technique to enhance performance is lazy loading. In this blog post, we will explore lazy loading in Blazor and understand how it can improve the loading speed and responsiveness of your applications.

What is Lazy Loading? 

Lazy loading is a technique that defers the loading of certain resources or components until they are actually needed. Instead of loading everything upfront, lazy loading allows you to load specific parts of your application on-demand, reducing the initial load time and improving overall performance.

Benefits of Lazy Loading in Blazor

  1. Faster Initial Load: By loading only the essential components and resources during the initial page load, lazy loading minimizes the amount of data transferred, resulting in faster load times.
  2. Reduced Bandwidth Usage: Lazy loading helps conserve bandwidth by fetching additional components or data only when they are required. This is particularly beneficial for mobile users or those on slower network connections.
  3. Improved User Experience: With lazy loading, users can start interacting with the application sooner, as they don’t have to wait for the entire application to load. This improves the perceived performance and provides a more responsive user experience.

Implementing Lazy Loading in Blazor

To implement lazy loading in Blazor, we can leverage the dynamic component loading feature introduced in Blazor .NET 6.

  1. Identify the Components to Lazy Load: Analyze your application and identify components that are not immediately necessary on the initial page load. Examples may include complex data grids, charts, or sections of the application that are accessed less frequently.
  2. Create Placeholder Components: For the components that will be lazily loaded, create lightweight placeholder components that are initially rendered in their place. These placeholders can be simple loading spinners or placeholders with minimal content.
  3. Load Components On-Demand: When the user triggers an action or navigates to a section requiring a lazily loaded component, dynamically load the actual component and replace the placeholder. This can be done using mechanisms like RenderFragment or by utilizing third-party libraries such as Blazor.Lazy.
  4. Manage State and Data Dependencies: Consider any state or data dependencies of the lazily loaded components. Ensure that the necessary data is available and propagated to the components when they are loaded.
  5. Graceful Error Handling: Handle any errors that may occur during the lazy loading process, such as network failures or component loading failures. Provide informative error messages or fallback options to prevent a poor user experience.

Sample Lazy loading

Here are a few code snippets to illustrate the implementation of lazy loading in Blazor

1. Placeholder Component 

lazy loading in Blazor example 1

2. Lazily Loaded Component

lazy loading in Blazor example 2

3. Lazy Loading in Parent Component: 

lazy loading in Blazor example 3

In the example above, the PlaceholderComponent serves as a lightweight component initially rendered in place of the LazilyLoadedComponent. The LazyComponent from the Blazor.Lazy library is used to encapsulate the lazy loading functionality. When the LoadLazilyLoadedComponent method is invoked, it simulates an asynchronous loading delay and then replaces the placeholder with the actual LazilyLoadedComponent.

Remember to include the necessary using statements and reference any required libraries in your Blazor project to utilize lazy loading functionality.

These code snippets provide a basic implementation of lazy loading in Blazor. You can further enhance and customize the implementation based on your specific requirements and application structure.

The code snippet provided uses the Blazor.Lazy library as an example. Make sure to install the library via NuGet or use an alternative lazy loading solution if desired 

Conclusion: 

Lazy loading is a powerful technique in Blazor to optimize performance by deferring the loading of non-critical components and resources until they are needed. By reducing the initial load time and conserving bandwidth, lazy loading can significantly enhance the user experience of your Blazor applications. Remember to identify the right components to lazy load, create placeholders, and load components on-demand while considering state management and error handling.

By adopting lazy loading techniques in your Blazor applications, you can deliver fast, responsive, and highly performant web experiences. So, why wait? Start leveraging lazy loading in Blazor today and take your application performance to the next level!

Additionally, if you want to explore more about the topic, you can check out the informative blog post titled “Creating Static Images in Blazor: A Complete Guide” for further insights and guidance.

Categories
Technology

Creating Static Images in Blazor: A Complete Guide

Blazor is a popular web framework that allows developers to create web applications using C# instead of JavaScript. It provides a simple, elegant, and efficient way to build client-side applications that run in any modern web browser. In this article, we will be exploring the creation of static images in Blazor. We will cover the basics of how to add and display images in a Blazor application, as well as some advanced techniques for optimizing images for better performance.

Understanding Image Formats

Before we dive into the specifics of creating static images in Blazor, it is important to understand the different image formats available and their respective advantages and disadvantages. There are three primary image formats used on the web: JPEG, PNG, and GIF.

JPEG is a lossy image format that is best suited for photographs and other complex images with many colors. It is a compressed image format that reduces file size by removing some of the image’s original data. While this compression can result in a loss of image quality, it can also greatly reduce file size, making it ideal for use on the web.

PNG is a lossless image format that is best suited for images with fewer colors, such as logos, icons, and other graphics. Unlike JPEG, PNG compression does not remove any image data, resulting in higher image quality but larger file sizes.

GIF is a lossless image format that supports animation. It is best suited for simple animations and other small, lightweight graphics.

Adding Images to a Blazor Application

Adding images to a Blazor application is a straightforward process. First, you need to include the image file in your project’s wwwroot folder. This folder is used to store static files that can be served directly by the web server.

Once you have added the image file to your project, you can reference it in your HTML or Razor code using the  tag. For example, the following code displays an image named “logo.png” in a Blazor component:

<img src=”/logo.png” alt=”My Logo” />

In this code, the “src” attribute specifies the location of the image file, and the “alt” attribute provides alternative text that is displayed if the image cannot be loaded or is inaccessible to visually impaired users.

Optimizing Images for Better Performance

While adding images to a Blazor application is easy, it is important to optimize them for better performance. Large, unoptimized images can slow down the loading time of your web pages and negatively impact the user experience. There are several techniques that you can use to optimize images in a Blazor application:

Reduce Image Size: One of the simplest ways to optimize images is to reduce their size. This can be done by compressing the image using a tool like TinyPNG or by resizing the image to a smaller resolution. This reduces the file size of the image, making it faster to load.

Use Responsive Images: Responsive images are images that are served in different sizes depending on the screen size of the device. This ensures that the image is always displayed at the appropriate size and resolution, improving the user experience.

Lazy Loading: Lazy loading is a technique that defers the loading of non-critical resources, such as images, until they are needed. This can greatly reduce the initial load time of your web pages and improve performance.

Conclusion

In conclusion, creating static images in Blazor is a simple process that involves adding the image file to your project’s wwwroot folder and referencing it in your HTML or Razor code using the tag. However, it is important to optimize your images for better performance by reducing their size, using responsive images, and lazy loading.

Additionally, if you want to explore more about the topic, you can check out the informative blog post titled “The Ultimate Guide to Blazor Forms and Validation” for further insights and guidance.

Categories
Technology

Vue vs React vs Angular: Which is the Best Choice for your Project?

If you’re planning to develop a web application, you might have heard about Vue, React, and Angular. These three are the most popular and widely used frontend frameworks among web developers. Each of these frameworks has its own advantages and disadvantages, and choosing the right one can be a daunting task. In this blog post, we’ll compare Vue, React, and Angular to help you decide which one is the best choice for your project.

Vue.js

Vue.js is a lightweight and progressive JavaScript framework used for building user interfaces. It was created by Evan You in 2014 and has gained popularity because of its simplicity and ease of use. Vue.js is a reactive framework that updates the view automatically when the data changes.

One of the significant advantages of Vue.js is its small size, which makes it an excellent choice for building small to medium-sized applications. Vue.js is also easy to learn, and you can get started with it quickly, even if you’re a beginner. Vue.js has a comprehensive documentation and an active community that provides support and assistance to developers.

Another advantage of Vue.js is its flexibility. You can integrate Vue.js with other libraries and frameworks like React or Angular, which makes it an excellent choice for developing hybrid applications. Vue.js also supports server-side rendering, which improves the performance of web applications.

React

React is a popular JavaScript library for building user interfaces. It was created by Facebook in 2011 and is widely used by large companies like Netflix, Airbnb, and Instagram. React uses a virtual DOM, which improves the performance of web applications by reducing the number of DOM manipulations.

One of the significant advantages of React is its performance. React uses a virtual DOM, which makes it faster than other frameworks like Angular. React also has a large community that provides support and assistance to developers.

React is also flexible and can be used with other libraries and frameworks. You can use React with Vue.js or Angular to develop hybrid applications. React also has a vast ecosystem of third-party libraries and tools that make it easy to develop complex web applications.

Angular

Angular is a popular JavaScript framework for building web applications. It was created by Google in 2010 and is widely used by large companies like Microsoft, IBM, and PayPal. Angular is a full-featured framework that provides everything you need to develop complex web applications.

One of the significant advantages of Angular is its robustness. Angular provides a complete solution for building web applications, including data binding, forms, and routing. Angular also has a large community that provides support and assistance to developers.

Angular also has excellent performance. Angular uses a virtual DOM, which makes it faster than other frameworks like Vue.js. Angular also provides server-side rendering, which improves the performance of web applications.

Vue vs React vs Angular

Now that we’ve looked at the advantages of each framework, let’s compare them to help you decide which one is the best choice for your project.

Learning Curve

When it comes to the learning curve, Vue.js is the easiest to learn. Vue.js has a small API and is straightforward to understand, even if you’re a beginner. React and Angular, on the other hand, have a steeper learning curve. React uses JSX, which can be challenging to learn, and Angular has a lot of concepts that you need to understand before you can start developing web applications.

Performance

When it comes to performance, React and Angular are the clear winners. React uses a virtual DOM, which makes it faster than Vue.js. Angular also uses a virtual DOM and provides server-side rendering, which improves the performance of web applications.

Flexibility

When it comes to flexibility, Vue.js is the clear winner. Vue.js is a lightweight framework that can be easily integrated with other libraries and frameworks. React and Angular are also flexible, but they have a slightly steeper learning curve when it comes to integration with other technologies.

Robustness

When it comes to robustness, Angular is the clear winner. Angular provides a complete solution for building web applications, including data binding, forms, and routing. React and Vue.js are more focused on the view layer and require additional libraries for routing and state management.

Community and Ecosystem

All three frameworks have active communities that provide support and assistance to developers. However, React has the largest ecosystem of third-party libraries and tools. Vue.js also has a vibrant ecosystem, but it is not as large as React’s. Angular also has a large ecosystem, but it is more focused on enterprise applications.

Which one is the best choice for your project?

The answer to this question depends on the specific requirements of your project. If you’re building a small to medium-sized application and want a lightweight and easy-to-learn framework, Vue.js might be the best choice. If you’re building a large application that requires excellent performance and a large ecosystem of third-party libraries, React might be the best choice. If you’re building an enterprise-level application that requires a complete solution for building web applications, including data binding, forms, and routing, Angular might be the best choice.

Conclusion

Vue.js, React, and Angular are all excellent frontend frameworks that have their own advantages and disadvantages. The best choice for your project depends on the specific requirements of your application. Vue.js is a lightweight and easy-to-learn framework that is an excellent choice for small to medium-sized applications. React is a popular and performant framework that has a large ecosystem of third-party libraries and tools. Angular is a robust framework that provides a complete solution for building web applications, including data binding, forms, and routing. Whatever framework you choose, make sure to take the time to learn it properly and follow best practices to ensure the success of your project. For any further information, visit – https://techcedence.com/ 

Categories
Technology

The Ultimate Guide to Blazor Forms and Validation 

This blog will explain how to implement Forms and Validation in Blazor. The EditForm component aids in the validation of webforms and data annotations.

Let’s look at how the EditForm component handles data annotation validation.

Consider the Student class file below.

All of the class properties are marked with the [Required] attribute in this case. It specifies that the value of the data field is required. [MinLength(3)] attributes are assigned to the Name. It specifies the shortest string data allowed in name. The [Range] attribute is assigned to the DateOfBirth property. The range has been set to “1/1/2000” to “1/1/2010”. As a result, the date of birth should be between “1/1/2000” and “1/1/2010”. Also, the ErrorMessage property has been set, so if the user enters an invalid date of birth, the error message will be displayed.

Demo.cs
using System.ComponentModel.DataAnnotations;

namespace SampleBlazorApp.Data
{ 
    public class Student
    {
        [Required]
        [MinLength(3)]
        public string Name{ get; set; }
        
        [Required]
        public string Gender { get; set; }

        [Required]
        [Range(typeof(DateTime), "1/1/2000", "1/1/2010",
        ErrorMessage = "The date of birth should between 1/1/2000 to 1/1/2010")]
        public DateTime DateOfBirth { get; set; } = Convert.ToDateTime("1/1/2000");
    }
}

The code for a razor component is as follows. A form attribute is created by the EditForm element. It displays the form element. In the @code area, the student model is created. The student model is assigned the Model attribute in the EditForm component. As a result, it binds the student model to the form. The SaveData method is assigned to the EditForm‘s OnValidSubmit attribute. The SaveData  method will be executed if no validation errors occur. For example, if any of the input fields are empty, the validation summary will display the message like “The name field is required”. That means the validation process isn’t finished. The SaveData method is not called in such cases.

In the code below, an InputText component is added to add and edit string values. The InputDate component has been added to collect the date of birth value. The @bind-Value directive attribute aids in binding model values to the component value properties InputText and InputDate.

index.cshtml
@page "/"
@using SampleBlazorApp.Data

<EditForm Model="@student" OnValidSubmit="SaveData">
    <DataAnnotationsValidator />
    <ValidationSummary />

    <p>
        First Name:
        <InputText @bind-Value="@student.FirstName"></InputText>
    </p>
    <p>
        Last Name:
        <InputText @bind-Value="@student.LastName"></InputText>
    </p>

    <p>
        Gender:
        <InputText @bind-Value="@student.Gender"></InputText>
    </p>

    <p>
        Date of Birth:
        <InputDate @bind-Value="@student.DateOfBirth"></InputDate>
    </p>

    <p>
        Address:
        <InputText @bind-Value="@student.Address"></InputText>
    </p>
    <button type="submit">Submit</button>
</EditForm>

@code {
    private Student student = new Student();

    private void SaveData()
    {
        // data save code
    }
}

The following is the output of the above code. Here you can see that when the user clicks on the submit button it gives a summary error message. The error message disappears when the user enters the correct values.

blazor validation 1

Must True Validation

The user may be required to acknowledge something like ‘I accept the terms and conditions’ at times. If this is the case, the checkbox must be selected before submitting the form.  Let’s look at how to do that with data annotation validation.

A demo class file is provided below. It has two properties: Name and IsAccepted. The property IsAccepted must be true. So, the range validation attribute was used here. The data type bool has been specified. The minimum and maximum values are both set to “true.” If it is false, it means the user did not check the checkbox, and the error message will be displayed.

Demo.cs

using System.ComponentModel.DataAnnotations;

namespace SampleBlazorApp.Data

{
    public class Demo
    {
        [Required]
        [MinLength(2)]
        public string Name { get; set; }

        [Range(typeof(bool), "true", "true", 
            ErrorMessage = "Accept the terms and conditions")]            
        public bool IsAccepted { get; set; }
    }
}

The following is a razor page code. 

index.razor
@page "/"
@using SampleBlazorApp.Data

<EditForm Model="@demo" OnValidSubmit="SaveData">
    <DataAnnotationsValidator />
    <ValidationSummary />

    <p>
        Name:
        <InputText @bind-Value="@demo.Name"></InputText>
    </p>
    <p>
        <InputCheckbox @bind-Value="@demo.IsAccepted"></InputCheckbox> I accept the terms and conditions
    </p>

    <button type="submit">Submit</button>
</EditForm>

@code {
    private Demo demo = new Demo();

    private void SaveData()
    {
        // data save code
    }
}

The image below is the result of the above code. The range validation is demonstrated here.

blazor validation 2

Validation for Specific Field

The preceding examples demonstrate how to display the error message in summary. However, if you want to display a specific error message, you can use the <ValidationMessage> component. The code below demonstrates the specific field validation. The <ValidationMessage> attribute has been added next to the Name and Age textboxes.

index.cshtml
@page "/"
@using SampleBlazorApp.Data

<EditForm Model="@demo" OnValidSubmit="SaveData">
    <DataAnnotationsValidator />

    <p>
        Name:
        <InputText @bind-Value="@demo.Name"></InputText>
        <ValidationMessage For="@(() => demo.Name)" />
    </p>
    <p>
        Age: 
        <InputNumber @bind-Value="@demo.Age" ></InputNumber>
        <ValidationMessage For="@(() => demo.Age)" />
    </p>

    <button type="submit">Submit</button>
</EditForm>

@code {
    private Demo demo = new Demo();

    private void SaveData()
    {
        // data save code
    }
}

The above code produced the following result. When the user enters the age 5 here, the error message appears right next to the age textbox.

blazor validation 3

Handle Form Submission

To handle the form submission, the EditForm provide following callbacks

OnValidSubmit – This will call the assigned event handler when the user has entered all valid entries

OnInvalidSubmit – This will call the assigned event handler when the input value is no or any value is invalid

OnSubmit – This will call the assigned event handler whether the form is valid or not.

Built-in form component

The Blazer framework provides some built-in input components to obtain input values. The following is a list of built-in form elements

Input ComponentRendered Element
InputCheckbox<input type=”checkbox”>
InputDate<input type=”date”>
InputFile<input type=”file”>
InputNumber<input type=”number”>
InputRadio<input type=”radio”>
InputRadioGroupGroup of child InputRadio
InputSelect<select>
InputText<input>
InputTextArea<textarea>

Conclusion

From this blog you can understand how form and data annotation validation works in Blazor. Also, You can also find coding examples for various types of validation. I hope you find this blog useful.

Read our blog for valuable insights on Static Image in Blazor

Categories
Technology

Why DevSecOps is the Need of the Hour?

DevOps blurs the lines between development and operations. It blends both these aspects to help companies deliver software applications better and quicker. In 2021, over 80 percent of IT decision-makers implemented DevOps to tap a higher business value!

But like every other technology and approach, DevOps also has its story of evolution to tell. DevSecOps, the evolved form of DevOps, is precisely what we are referring to here.

Earlier, usually, development used to be almost every company’s prime focus. Security was often an afterthought. But ever-evolving and rising security concerns encouraged DevOps to evolve into DevSecOps, a much better approach to software development. Experts look at DevSecOps as the need of the hour. Let’s examine a few reasons.

What is DevSecOps?

DevSecOps is development, security, and operations. It is an approach that introduces security earlier in the software development lifecycle (SDLC). In addition, it broadens the collaboration between the development and operations teams to integrate security teams in the software development lifecycle. 

DevSecOps demands a change in the process, tools, and culture across the cure verticals and makes security a shared onus. Thus, every element of the SDLC plays a role in building security in the DevOps CI/CD workflow.

While this is understood and signifies the importance of DevSecOps in the current context, let’s delve into a few reasons that make DevSecOps the need of the hour.

5 Reasons DevSecOps is Crucial to Your Business

Reasons DevSecOps is Crucial to Your Business

Fundamentally, DevSecOps introduces the security aspect from the initial stages of the software development process. But in addition to it, it has various other benefits that make this approach significant. Let’s assess those facets.

1. Shortened Development Cycle

The conventional software development approach involves development, operations, and security teams working separately. Every team in the sequence has to wait for the previous team to finish its task and start its job.

Working with such an approach could delay product development and release. Besides, defects in the product take it back into the cycle, thus requiring even more time, effort, and cost to develop and release. Let alone the product’s quality that suffers!

But DevSecOps integrates all these teams that work collaboratively and simultaneously. It helps cut short the development cycle, as the product is developed, tested, and rectified at the same time. The result is a better, quicker, and more secure product.

2. Increased Proactiveness

DevSecOps refers to a proactive approach, as it has all three core teams working collaboratively and simultaneously. So, while the development team continues developing, the testing unit ensures frequent testing and detection of security vulnerabilities while the development is in progress. Rectification happens immediately after the fault is detected. Nothing is kept to deal with it at a later stage, especially security, dealing with the gaps which would later become herculean!

3. Reduced Development Cost

Imagine discovering a critical security defect (which initially went unnoticed or left unattended) after the product’s launch! Rectifying it could double the development cost, especially if it requires significant architectural changes. 

But DevSecOps takes care of all these aspects from the initial stages. While it takes an expert to integrate this approach, it is way more prudent investing in experts rather than resources you might have to employ later to cover things up. In a nutshell, DevSecOps reduces the overall development cost.

4. Increased Flexibility and Adaptivity

DevSecOps embeds security into the design and development process. Hence, while ensuring enhanced and stronger security, this fundamental approach allows for better flexibility in handling sudden changes. It is also because DevOps involves rolling out the development process in smaller chunks, to which continuous testing is integral. Thus, the team can make changes without reinventing the wheel.

5. Automation

DevSecOps can help companies automate various security protocols, thus increasing the efficiency and operational pace of the project’s security team. Thus, they can focus on more strategically and technically more complicated tasks. 

Integrate DevSecOps seamlessly with Techcedence. Our software development expertise and the ability to drive results via contemporary approaches can help you leverage the benefits of DevSecOps and develop better software products. 

Our team of consultants, developers, testers, and project specialists collaborate to comprehend your needs and use the DevSecOps approach to achieve high speed, quality, security, flexibility, and adaptability levels. Connect with us at sales@techcedence.com to interact with our experts.

Categories
Technology

Static Image in Blazor – Inside and Outside Web Root

This article explains how to display a static image in the Blazor component. In ASP.NET Core  static files are served by Microsoft.AspNetCore.StaticFiles middleware. First, let’s look at the general way to display the image in the Blazor component.

Inside the Web Root

To display a static image in the Blazor component, first, it must store the image in any folder under the wwwroot file. It can be accessed by the relative path. To serve a static image, you need to use the app.UseStaticFiles () method in the start.Configure file.

The following is the Blazor component code. Here the image is obtained from {applicationFolder} /wwwroot/Image/InsideWebRoot.png.

@page “/”
<h3> Display Image in Blazor</h3>
<div>
    <img  src=”/Image/InsideWebRoot.png”   />
</div>
@code {
}

Outside the Web Root

The static file can also be served outside the web root. Consider the following image, here the StaticFilesFolder/Image is created outside the wwwroot folder.

Static Image

To serve this, you first need to configure the UseStaticFiles () method in the Startup.cs file. In the following code, UseStaticFiles uses FileProvider to locate the static file. PhysicalFileProvider is used to access the physical path. The request path is set to “/staticFiles”, which is mapped to the static file.

public void  Configure(IApplicationBuilder  app, IWebHostEnvironment env)
{
    app.UseStaticFiles();
 
    app.UseStaticFiles( new StaticFileOptions
    {
FileProvider = new  PhysicalFileProvider(
       Path. Combine(Directory . GetCurrentDirectory(), “StaticFilesFolder” )),
RequestPath = “/StaticFiles”
    });
}

The following is the Blazor component code. The static image path in the img tag is assigned as “/StaticFiles/Image/OutsideWebRoot.png”. The /StaticFiles is a RequestPath that is configured in the startup.cs file. So the following code will show the static image that is outside the web root.

@page “/”
<h3> Display Image in Blazor</h3>
<div>
    <img  src=”/StaticFiles/Image/OutsideWebRoot.png”  />
</div>
@code {
}

This article explains how to display a static image in Blazor Component.

If you have questions, please leave a comment.

Categories
Technology

Cyber Security

Cyber Security refers to the protection of data, network, servers and mobile devices from unauthorized access. It is important for any Organization including bank, Government, healthcare, and manufacturing sector to protect data stored on their system and information transmitted over the network from malicious attacks. Cyber attacks are targeting data related to national security, finance, health care records, business, and personal information.

Effective cyber security should take care of all the elements below:

  • Network security refers to securing a computer network from malware or targeted attacks. A network that is not secure is vulnerable to attacks.
  • Cloud security refers to the protection of data, application, infrastructure, and anything stored on the cloud from theft and deletion.
  • Database security refers to protecting databases, database management systems from external attacks.
  • Infrastructure security refers to protecting the communication center, IT center from targeted or random threats.
  • Application security refers to protecting software applications from security threats to avoid data theft.
  • Information security refers to protecting the integrity and privacy of data.  A cyberattack can target confidential or sensitive information.

Some of the common cyber threats include:

Malware – these are malicious software programs designed to gain unauthorized access to a person’s computer and cause damage. Malware can steal data, login information or crash your system. Some types of malware include spyware, adware, Trojan horse, viruses and worms.

Ransomware – it is also a form of malware that gains access to a system, restrict user access or encrypts the data and demands a ransom. The user cannot log in to their device or access the data unless they pay the ransom. Ransomware attacks target individuals and organizations through phishing emails or free downloads. Some ransomware examples include WannaCry and GoldenEye.

Measures to combat Cyber Threat

Awareness – The most common reason for a cyberattack is due to lack of awareness among users. Failing to adopt good security practices makes a system vulnerable. It is essential to impart knowledge on various security measures to users like deleting suspicious email attachments or files, installing security software, updating devices with security patches, taking back up of files regularly, trusting URLs with ‘https’.

Avoid Ransomware attack – Never open an email from untrusted sources. Pay extra caution if the attachment instructs to enable a macro. If you become a victim of a ransomware attack, never pay the ransom as the chance of getting back your data is very less. Instead, contact the internet security vendor for a suitable decryption tool.

Mitigate the risk of cyber attacks – It is essential to train employees on secure handling of information to maintain a high level of security. An organization should educate employees about security threats, password policies and the need for updating antivirus software through seminars and sessions. Another approach to mitigate cyberattacks is through firewall and proxy server which will block unsecured websites.

Disaster Recovery – Every Organization should have a disaster recovery policy in place. The disaster recovery plan should define how the organization will respond to a cyber attack and restore its operation to ensure business continuity. Companies should take data back up at regular intervals to avoid losing vital business information. It is important to stay ahead and keep track of the latest security threats and new security settings.

Hope this article gives you insights into cybersecurity and how to avoid becoming a victim of a cyber attack.

Categories
Technology

Web Development Framework

A Web Development Framework refers to a structure used to develop web applications. The framework comprises a set of tools and resources to build your application faster. The framework eases the development work by providing a foundation to build a content management system. It provides libraries and functions that can help to develop applications instead of writing the code from scratch.

There are many frameworks available to develop web applications. A web application has two parts – front end and back-end. While front end refers to interactive components on the website, back end refers to database and storage. There are frameworks available for both the front end and back-end development. You can pick the right one by weighing the pros and cons.

Backend Framework

Laravel

Laravel is a PHP framework and is suitable for developers who have knowledge in HTML, Core PHP, and Advance PHP. The advantage of a PHP framework is that it allows rapid development of web applications. Laravel is a free, open-source framework that provides functions for caching, session and authentication. It provides a secured framework and helps to protect the application from malware and security threats.

Express

Express is a NodeJS framework that can help in developing server-side web applications. The advantages of this framework is it is free, open-source, simple, flexible and scalable and can develop web applications faster. Express is used by IBM and Uber.

Django

Django is a MVC framework that uses Python for rapid web development. This framework is free and open source. It is used by Google, Youtube and Instagram. The main advantage of this framework is that it comes with batteries included features that provide authentication, URL routing, and messaging features. Django’s performance keeps increasing and it provides an online forum and discussion group that can help in troubleshooting.

Rails

Ruby on Rails is an extremely efficient framework. It is used to develop applications 10 times faster than java framework. This framework is a friendly and supportive framework for beginners.

Applications developed using this framework include Airbnb and Shopify.

Spring

Spring is a Java framework. It is often considered a lightweight framework as it uses the Plain Old Java Object (POJO). It provides modularity allowing developers to choose packages and classes of their choice. The downside is that the spring framework has 2400 classes which might be complicated for the developer. This framework requires developers to have XML knowledge.

Frontend Framework

Angular

Angular is Typescript based framework provided by Google. It is used to develop high-performance web applications for both mobile and web platforms. It is ideally used to build complex applications and considered superior among other Javascript frameworks. Angular has lots of handy tools and features like static typing, interfaces, namespaces, and classes which make development process faster and easier. There are some challenges in using the Angular framework. As Angular is built using TypeScript, the developers need to be familiar with Typescript which is a superset of Javascript. 

React JS

React JS is not exactly a framework but a front end library developed by Facebook. It is used to develop both client or server-side.

React is a Javascript framework developed by Facebook. It is the wide choice of developers to build an interactive user interface and single page web applications. The advantages of using React is it is open source and has an active community. It is a Javascript library and supports code reusability and one side data binding.

Bootstrap

Bootstrap is a front end framework used to build responsive web and mobile-friendly websites. This open-source framework by Twitter uses HTML, CSS, and Javascript. This framework has good community support and provides continual fixes and releases. It offers templates, WordPress themes, and plugins that help to develop dynamic web pages faster.

Ember

Ember is among the best Javascript framework and it is gaining popularity as it gets updated with new features and releases. It is widely used by developers to build single-page web applications. It is used by Google, Microsoft and Netflix. It uses MVC architecture and has lots of features to increase developers’ productivity. It is the heaviest framework and not suitable for smaller projects.

Backbone

Backbone is a frontend Javascript framework used to build client-side applications. Backbone library provides the functionality to build a design with fewer lines of code. It is a free open source library that provides views, models, and events to build an application.

In short, a development framework can ease the work for developers and help to speed the development process.

Categories
Technology

Internet of Things (IoT)

Internet of Things (IoT) is the latest technology used in everyday life. In the digital world we live in, IoT has a major role to play in making our life easier and smarter. It is behind many applications that we are using today. It offers smart devices to automate things at work and at home.

This blog briefs about what is IoT and some of its applications and the future of IoT.

What is Internet of Things (IoT)?

Internet of Things refers to a network of objects connected to the Internet and can transfer data without any human intervention. The objects can be any physical device beyond computers and smartphones which can sense and communicate with each other. Some examples of objects include car, light bulb, thermostat, gate, etc.

Connecting devices helps to automate manual tasks at home or in office. Smart homes and Smart City are possible through IoT. Some typical examples of IoT in a smart home are a gate that opens when the car arrives, a door that unlocks automatically, thermostat inside the house adjusted to preferred room temperature and light that goes on sensing the movement of door. These devices can also be operated remotely. For example, you can turn off the lights at home while you are at your office desk using your smart phone.

It is widely used in factories and warehouses to automate production or deal with logistics.

How IoT Works

The IoT architecture comprises of sensor-enabled devices with internet connectivity. The devices communicate with each other through the sensors. The devices collect data through the sensors and the data is sent to the IoT Platform(cloud).  Bluetooth or Wi-Fi is required to transmit data from devices to Cloud. The data is analyzed and triggers action based on data found. The action can be anything like adjusting the temperature of the ac, switching on a light bulb or notifying the user on his mobile app. The devices are automated and perform these actions without any manual intervention.

Uses of IoT

The Internet of Things is changing the world we live in a smart place. Here are some of the applications of IoT across different industries.

Smart Homes: Smart homes make it possible to remotely monitor your residence for lighting, heating and security. Smart cameras allow monitoring your home while you are away travelling. Smart locks can detect owners and unlock the door automatically. Plants can be watered at regular intervals and Cars can drive you to work. Other smart devices that can be automated to make your life easier include fridge, laundry machines, thermostats, and even coffee machines.

Smart Offices: Smart Offices has a number of devices connected to each other and manages operations automatically. The conference room temperature is adjusted based on the number of people, lighting goes on and off through a motion sensor resulting in energy savings.

Smart Farming: IoT is used in farming to analyze the environmental condition, to monitor the field for moisture, humidity, temperature and automates irrigation. The application of IoT in farming will help to improve production and predict yield.

Smart Warehouse: IoT enables complete warehouse automation by tracking the movement of items, monitoring inventory and avoiding picking error. A Smart warehouse uses devices, drones, sensors and RFID. Robots are employed for picking, putaway and truck loading without human intervention.

Smart Health monitoring system: IoT finds its use in remote health monitoring and can act as a life-saving system. It can monitor the health condition and trigger notifications when there is any change in the body functions of the patient.

Future of Internet of Things (IoT)

Internet of Things has a promising future across healthcare, manufacturing, production, and agriculture. Research shows that by 2025 around 75 billion devices will be connected to IoT worldwide.

According to a study, global spending on IoT hardware and software is expected to be $1trillion in 2022. Cities will rely on IoT to bring in smart infrastructure. Cities will be monitored with surveillance cameras and IoT sensors, traffic can be monitored remotely and security can be enhanced and the world will be a better place.

Categories
Technology

Cross-Origin Resource Sharing (CORS)

Cross-origin resource sharing (CORS) is a mechanism based on HTTP headers that permits restricted access to a resource with a different domain.

The browser restricts the web page of different origin, this mechanism is called same origin policy. For example, https://www.demo.com/abc.html and https://www.demo.com/xyz.html these two urls are of the same origin. Consider the following urls:

  • http://www.demo.com – Different scheme: In this URL you can see that the protocol is ‘http://’ not ‘https://’. The ‘s’ (secure) is missing. 
  • https://www.demo.com:1234/abc.html – Different port number. The port number is a communication endpoint. In this URL the port no is 1234.

These kinds of different origins are blocked by browser security.

But sometimes the web page has to request some of the resources from different origins. In such cases you can use the Cross Origin Resource Sharing (CORS) as it allows the server to relax the same origin policy. 

Same Origin Policy

The same origin policy will restrict the website interacting with the resource from different domains.It helps prevent personal data from being stolen from one website to another.

How CORS Works

To make CORS Work you will have to add the new HTTP header that describes which origins allow you to read the information. To enable the CORS on the server, you have to add an additional header (Access-Control-Allow-Origin) to whitelist the urls. 

For example, if your API server is hosted in https://api.demo.com/customer and the CORS is configured in it, when you access the API from https://www.sample.com webpage it will send a response with the following header:

Access-Control-Allow-Origin: https://www.sample.com

The following image illustrates how CORS works. The client sends the request to the server API and the server API sends back the response with the header Access-Control-Allow-Origin: https://www.sample.com

Cross-Origin Resource Sharing

Also, you can use wildcard character(*), which means that the resource can be accessed by any origin.

Access-Control-Allow-Origin: *

Preflight Request

The preflight request is a small request sent by  the browser before the original request.  This will give the server an idea about the actual request.The server will then announce whether or not to send a request to the browser. The preflight request contains metadata about the HTTP method and additional request header. The server inspects the metadata and decides whether or not to send the request.

CORS

Note:

If the CORS policy is not properly configured, then it  leads to cross-domain based attacks.