Browsed by
Category: .Net

Access-Control-Allow-Origin Header and the ASP.NET Web API

Access-Control-Allow-Origin Header and the ASP.NET Web API

Adding Header Information in Web.config <system.webServer> <httpProtocol> <customHeaders> <add name=”Access-Control-Allow-Origin” value=”*” /> <add name=”Access-Control-Allow-Headers” value=”Content-Type” /> <add name=”Access-Control-Allow-Methods” value=”GET,POST,PUT,DELETE,OPTIONS” /> <add name=”Access-Control-Allow-Credentials” value=”true” /> </customHeaders> </httpProtocol> </system.webServer> As you can see we have added keys with value for the listed items.   Access-Control-Allow-Origin (For Origin) Access-Control-Allow-Headers (For Headers) Access-Control-Allow-Methods (For Methods) source :¬†https://dzone.com/articles/access-control-allow-origin-header-and-the-aspnet  

Fastest way to create instance of a Type in Runtime C#

Fastest way to create instance of a Type in Runtime C#

When working with refactoring and loading and creating instances of types in run time using c# the important factor you should take care of is the performance and time needed to create this instance. we always need to create objects of a type and we should use the method that will not take too much time to create this object. In this thread, I am going to explain the most famous ways to do this and we will see the…

Read More Read More

C# Plugin Manager

C# Plugin Manager

Plugins and modules are widely used in almost any type of application. They enhance them with additional features. Beside adding features, plugins have the big advantage, that they separate code in a very clean and testable way. Even hundreds of plugins can be managed without problems, as their functionality is encapsuled in a single place. This tutorial will explain you, how to implement a C# plugin- and module application-architecure, which is quite simple, clean and easy to maintain! Differences between…

Read More Read More

How to use gitlab or any git provider with visual studio

How to use gitlab or any git provider with visual studio

Hello, To use gitlab or whatever git provider follow theses steps Make your project as git repository by executing the command git init Move to Team Explorer tab and click on changes ¬† Add your commit message and then commit changes. Select Remote Repository Copy the HTTPS url of your repository from git provider like gitlab Add the HTTPS url of the repository then click publish and visual studio will ask you to enter your credential for that git provider…

Read More Read More

Dynamic Validator

Dynamic Validator

Hello Again, In this tutorial I am using dependency injection to add rules for any class and use these rules later in validation process. using System; using System.Collections.Generic; using System.Text.RegularExpressions; namespace DynamicValidator { class Program { static void Main(string[] args) { Emp e1 = new Emp(); e1.id = 123; bool vv = e1.validate(); Console.WriteLine(“Validate: ” + vv.ToString()); e1.name = “Ahmed”; vv = e1.validate(); Console.WriteLine(“Validate: ” + vv.ToString()); e1.email = “[email protected]”; vv = e1.validate(); Console.WriteLine(“Validate: ” + vv.ToString()); Console.ReadKey(); } }…

Read More Read More

Dynamic Workflow

Dynamic Workflow

I tried to implement Dynamic Workflow and how we can create dynamic workflow functions and execute it in sequence, I used Inversion of control to achieve this . here is the idea code: using System; using System.Collections.Generic; namespace a1 { class Program { static void Main(string[] args) { WorkFlow wf = new WorkFlow(); wf._worklist.AddLast(new CreateEmpList()); wf._worklist.AddLast(new CreateEmpList()); wf._worklist.AddLast(new PrintEmpList()); wf._worklist.AddLast(new CreateEmpList()); wf._worklist.AddLast(new CreateEmpList()); wf._worklist.AddLast(new PrintEmpList()); wf.execute(); Console.ReadKey(); } } public interface IFunction { void execute(); } public interface IValidator {…

Read More Read More