Skip to main content


Enabling FxCop Code Analysis on .NET Core

Enabling FxCop Code Analysis on .NET Core. Description :- Code Analysis is important Because it is helpful from many aspects like Code Quality, Code Correctness, Code maintainability will remain great code for long time. Step 1.  Install Nuget Package : Microsoft.CodeAnalysis.FxCopAnalyzers   Click Here  to install Nuget. Refer Below screen shot additional packages will be installed after installing. Step 2. File with name FxCop.ruleset will be created in solution when you try to change action by right clicking on rule in visual studio as shown below. where you can find list of rule to be configured. If you have multi layer Architecture and you want to use similar ruleset for all layers then move ruleset file at parent level of project and add reference of that ruleset file to each project were we need to add FxCop rules. Ruleset path can be set at csproj level as below. I have added CodeAnalysisRuleSet within PropertyGroup with relevant path of code analysis r

Future of .Net and .Net Core

Future of .Net and .Net Core.   Microsoft just announced .NET 5, the next version Before some time Microsoft has announced new version of Core .NET Core 3.0. C# 8.0 is the latest version of C# language that is supported in Visual Studio 2019 and with .NET Core 3.0. Recently Microsoft revealed .NET Schedule for their upcoming frameworks plan. Microsoft has plan to release .NET 5 on 2020 it will be single solution replacing .NET Core 3 and .NET Framework 4.8, .NET 5 is a single unified platform for building software for all platforms and all devices. In Current situation There are two versions of Microsoft .NET, 1) .NET Framework and 2) .NET Core so going forward Microsoft will not manage two different Framework so they has come up with one version of .NET name as .NET 5, .NET 5 takes the best of .NET Core, .NET Framework, Xamarin, and Mono to provide libraries, APIs, and run-time to build applications for Windows, Web, Mobile, Android, tvOS, watchOS and WebAssembly an

How to Consume WCF service to Asp.Net Core

In this article we will undestand how we can consume Wcf Service into Asp.Net Core application. In Asp.Net core we cannot create WCF service as core don't support WCF development. but it doesn't mean we can't consume Wcf service in core project. However in Asp.Net Core there is a slight difference in Consuming WCF Service. In Asp.Net core you will notice that, we don’t have the option “Add Service Reference like in the older .Net Framework. Step 1 :  You will find Connected Service into your solution, Double click on Connected Service. show below in ref 1 screen. once you click on Connected Service then ref 1.1 screen will be display. ref 1 ref 1.1  Step 2 :  click on the configure button [Microsoft WCF Web service reference provider]. configure screen will be open. ref 2 Step 3 : In the configure WCF Service reference dialog, you can either provide the URL of the service or you can try the discover option, which will display all the

Multiple Enviroment Support in core.

Introduction. ASP.NET Core has introduce new feature and many more performance enhancement. ASP.NET Core configures app behavior based on the runtime environment using an environment variable. We can set any value to ASPNETCORE_ENVIRONMENT but three environment value are in-build supported by framework are Development, Staging, and Production. by default value of ASPNETCORE_ENVIRONMENT is Production. Description. Let use see how we can set ASPNETCORE_ENVIRONMENT using Visual studio. the environment variable settings can be specified in our project's debug profiles. Above image shows current environment is set as Development. when we are modify any settings within the project will be refect in launchSettings.json , launchSettings.json is located into properties folder. The "launchSettings.json" file holds the setting, which is specific to each profile used to launch the Application. core read environment variable value at app startup and store

Bundling And Minification Using In ASP.NET Core.

Nowadays no one like to use website which works slowly. Bundling And Minification help us to achive. Bundling and minification are two different performance optimizer you can use for your application to improve overall performance of application. Bundling and minification primarily improve the first page request load time. Once a web page has been requested, the browser caches the static assets (JavaScript, CSS, and images). Bundling : Bundling combines multiple files into a single file. Bundling reduces the number of server requests which are necessary to render a web asset, such as a web page. You can create any number of individual bundles specifically for CSS, JavaScript, etc. It ultimately reduces http request for static content. Minification : Minification removes unnecessary characters from code without altering functionality and also removing white space and commented code. The result is a significant size reduction in requested assets (such as CSS, images, and Ja

ASP.NET Core Startup Class and Program.cs

Introduction. Global.asax is no more in ASP.NET Core application. Startup.cs file is a replacement of Global.asax file in ASP.NET Core. Startup.cs file is entry point of application level it handle request pipeline. Startup class which triggers at first when application launches. Description. Now question is startup.cs file is mandatory or not? Yes, startup.cs is mandatory, it can be decorated with any access modifier like public, private, internal. multiple Startup classes are allowed in a single application. ASP.NET Core will select the appropriate class based on its Enviroment. If a class Startup{EnvironmentName} exists, that class will be called for that EnvironmentName . Should we need to define class name with startup.cs? No it is not necessary that class name should be Startup. We can define two method in startup file like ConfigureServices and Configure. Startup file example : public class Startup { // Use this method to add services to the containe

Custom AuthorizeAttribute in ASP.NET Core.

Introduction. Filter in MVC are attribute which can be apply to controller and action method. filters allow us to write our custom code before and after method execution. filters can be implemented into different level of scope Global, Class, and Method level. MVC provides different types of filters. The Authorization filter will run first and are used to determine whether the current user is authorized or unauthorized for the current request. In this article we will learn how to create custom authorization filter, were you can write your own authorization framework. Description. For creating Authorization filter IAuthorizationFilter interface must be inherited. For example, the following code demonstrate custom Authorization below CustomAuthorization attribute allow only Home controller to access the particular method under home controller class else it will return "error" in response if it is called via ajaxcall, otherwise it will be redirect to Sessi