Showing posts with label .net Core. Show all posts
Showing posts with label .net Core. Show all posts

Tuesday, 23 July 2019

List of important .net core commands for build and run the projects.

Hi Readers,

Here the list of important and day to day usage od .net core commands. All these below commands are basic one's which used to setup and run .net core applications.


1. To see information of dotnet core,
    dotnet --info

2. To see version of .net core
     dotnet --version

3. To create a new project template
    dotnet new <projectType>
    Ex: console, nunit, and many more..

4. To restore the libraries
    dotnet restore

5. To run the application
    dotnet run

6. To see list of available commands in .net core
    dotnet --help

7. To give a name for the project
    dotnet new console -o <ProjectOutputFolder>
    Ex: dotnet new console -o DotnetDemos 
 
8 . To build the project
     dotnet build

9. To run a specific project 
    dotnet run --project <projectName>
    Ex: dotnet run --project StudentDetails


This article is continuously update with new and helpful commands for our daily work.

Keep an eye on this article and learn by doing with these commands.

Happy Coding :)

Friday, 8 March 2019

[Solved] Fix CORS Policy between Angular and .net Core Web API

Hi Readers,

Are you facing the following issue:

Access to XMLHttpRequest at 'http://localhost:5000/api/auth/login' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Solution for the above problem is to enable CORS Policy in .NET Core WEB API project.

File: Startup.cs:

In Configure Method,
Add this line: app.UseCors(); on top of app.UseMvc();

In Configuration Services Method,

            services.AddCors(options =>
            {
                options.AddPolicy(builder =>
                {
                    builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod().AllowCredentials().Build();
                });
            });


In Client Side, Consider ClientApp is Angular Application
Inside Environments/environment.ts file add the following snippet

export const environment = {
production: false,
ApiBaseUrl : "http://localhost:5000/"
};


With the above codes, CORS policy issue is resolved and we process request and response without any issues.


Happy Coding:)

Tuesday, 5 February 2019

[Solved] The .NET CLI tools cannot be located. .NET Core debugging will not be enabled. Make sure .NET CLI tools are installed and are on the path.

Hi Readers,

This article gives you the solution for the following issue in visual studio code.


Issue: The .NET CLI tools cannot be located. .NET Core debugging will not be enabled. Make sure .NET CLI tools are installed and are on the path.



To fix this issue:

Step 1: Go to File -> Preferences -> Settings
Step 2: Press CTRL + P  and search for Settings.json
Step 3: Add this key-value pair: "csharp.suppressDotnetInstallWarning": true in Settings.json file under user settings section like below


Step 4: Save the file and restart visual studio code and will not be seen this visual studio warning message.

That's it from this article and hope you liked it and give your valuable comments and share this to your friends and beloved people..

Happy Coding:)