Search code examples
c#asp.netasp.net-mvcweb-deploymentrazor-pages

Where can I find or add the _AppStart & _PageStart in ASP.NET projects?


Let me start off by saying I've seen a StackOverflow question related to this but there's no question like this I want to ask!

In my learning journey of the framework ASP.NET, I find a little problem. When I create any new ASP.NET project using the dotnetCLI. by standard the projects are missing two files that i'm looking for the _AppStart and _PageStart. Where can i find them or how can i add them? Thanks


Solution

  • The _AppStart and _PageStart files belong to the old ASP.NET Web Pages framework. They are not supported in the new Razor Pages framework, which is what you are using when you create applications using the CLI.

    The equivalent to _AppStart in Razor Pages is the Program.cs file (.NET 6 onwards) or the Configure method in Startup (ASP.NET Core 2 - 5). The replacement for the _PageStart file is _ViewStart.

    The Web Pages framework is more or less dead. Two of its four pillars have been deprecated (SQL CE and WebMatrix) and the recommendation these days is that you use Razor Pages instead.

    https://www.learnrazorpages.com

    https://learn.microsoft.com/en-us/aspnet/core/razor-pages/?view=aspnetcore-6.0&tabs=visual-studio