All ASP.NET Core applications are self-hosted.
Yes you read it right!
So does it mean IIS is not required?
Yes, I mean we can host MVC6 application even without IIS.
Wow…but How?
I assume you have already downloaded .Net core from here.
Next step would be to create sample MVC6 project.
For now you can directly clone it from Github by below commands:
git clone https://github.com/NeelBhatt/cli-samples.git
cd cli-samples\HelloMvc
Then we would restore and run the project as below:
dotnet restore
dotnet run
That is it!
Now navigate to localhost:5000 in your web browser and you can see your application hosted there.
You must be wondering how it happened?
You can check it by yourself in code.
Open Program.cs class and you can see below code there:
public class Program
{
public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.AddCommandLine(args)
.AddEnvironmentVariables(prefix: "ASPNETCORE_")
.Build();
var host = new WebHostBuilder()
.UseConfiguration(config)
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration() //// Here IIS integration is optional
.UseStartup()
.Build();
host.Run();
}
}
As you can see in above comments, IIS integration is optional in .Net core.
Happy coding!
Has the GitHub repository moved?
LikeLike
Looks like it is moved, let me check.
LikeLike
Hi , This repository is not found on github! is it private or moved ?
LikeLike
Hello, Looks like it is moved, let me check.
LikeLike