ASP.NET Development MVC

How to write custom console command for ASP.NET MVC application? To execute like “dotnet run my-custom-command arg1 arg2”

I’m trying to find information over the internet, but everything around points just to dotnet cli utility.

It seems nobody or almost nobody asked for feature to have ability to run console command from MVC app.

My reasons to have it:

I have MVC app and I want to create custom console commands to:
– Insert administrator account into database
– Import excel file with new entities info into database
– Generate additional images

And I need custom cli commands inside MVC because cli commands will have to have access to services and database.

How to accomplish this in ASP.NET MVC/Web Api?

Leave a Reply

Your email address will not be published. Required fields are marked *