Skip to main content

Posts

Showing posts with the label .Net Core

Traditional file helper won't work in .Net core

Prior to .Net Core, we use to handle file by passing various sort of parameters, like -in memory bytes, FileStream or file path and that use to work perfectly.  But when it comes to .Net Core, passing a file path will not work exactly as ASP.Net MVC. In earlier versions, the path we supplied was considered as a physical path whereas in Core, same API is used to denote the virtual path. In other words, whatever path is provided will be appended with site URL.  Now how to give physical path in .Net Core?  No worries! Here comes the PhysicalFile helper for our rescue. To know more about it, here you go. Keep learning!

Invoking web application from console application (.Net Core) via command prompt

In this article, I’ll be giving a walkthrough on how to create a console application and changing that into a web application. Or in other words, invoking a web application from a .Net core console application. And that too completely from command prompt. If you are a command prompt lover, you may love it. So, let’s gear up and proceed step-by-step. Verify .Net Core If you are creating a .Net Core application for the very first time, then it is good to verify whether it is installed on the system or not and this can be done by typing a simple command  dotnet --version  as shown below:   Create Console application Now we are sure that required setup is present on our machine, we can proceed and create our first Console application  using command dotnet new console as shown below:   On successful execution of above command, you will see that Program file and project file is created in your local directory and same can be verified by opening Program.

Ways to add dependency packages in .NET core

This would be a very short article on how to add dependencies in .Net Core . Well, there are many ways to achieve this. One is via Visual Studio and another way is through command prompt. Let’s quickly have a look.  1) From Visual Studio:  This is the straight forward way for the ones who want to use user interface to add dependencies. Right click on your project/library and get it from Nuget gallery.  2) From Command Prompt:   If you are a command prompt fan, then there itself, you have 2 choices. A) Open command prompt. Navigate to your project directory and simply fire: C:\<Your project directory> dotnet add package Microsoft.AspNetCore   B) Alternative you can go and add the reference directly in .csproj file as shown below: and restore it from command prompt using very simple command: C:\<Your project directory> dotnet restore Happy learning!!!