The ASP.NET Interns ship their project - A basic blog template for .NET Core
They did their work over at https://github.com/VenusInterns/BlogTemplate so I'd encourage you to star their repository...and maybe get involved! This is a great starter application to explore ASP.NET and possibly do a pull request (make sure to give them a heads up in an issue before refactoring/changing everything ;) ) and contribute.
The interns used ASP.NET Core's new Razor Pages as well. Razor Pages sits on (is just) MVC so while it might initially look unfamiliar, remember that it's all still using the ASP.NET Core "MVC" pattern under the hood.
When you install the .NET Core SDK you'll get a bunch of standard templates so you can:
- dotnet new console
- dotnet new mvc
- dotnet new console --language F#
There are lots of 3rd party and community templates and the beginnings of a website to search them. I expect this to be more formal and move into docs.microsoft.com in time.
The interns made "dotnet new blog" where blog is the short name of their template. They haven't yet released their template into NuGet for folks to easily install "dotnet new -I blogtemplate.whatever," For now you'll need to clone their repo as if you were developing a template yourself. It's actually a decent way for you to learn how to make templates.
Try this, using the .NET Core 2.0 SDK.
C:\> git clone https://github.com/VenusInterns/BlogTemplate.git
C:\> dotnet new -i C:\BlogTemplate -o C:\myblog
C:\> cd \myblog\BlogTemplate
C:\myblog\BlogTemplate> dotnet run
C:\myblog\BlogTemplate (master) > dotnet run
Using launch settings from C:\myblog\BlogTemplate\Properties\launchSettings.json...
Hosting environment: Development
Content root path: C:\myblog\BlogTemplate
Now listening on: http://localhost:59938
Application started. Press Ctrl+C to shut down.
And here's my nice local new blog. It's got admin, login, comments, the basics.
At this point you're running a blog. You'll see there is a Solution in there and a project, and because it's a template rather than a packaged project, you can open it up in Visual Studio Code and start making changes. This is an important point. This is an "instance" that you've created. At this point you're on your own. You can expand it, update it, because it's yours. Perhaps that's a good idea, perhaps not. Depends on your goals, but the intern's goal was to better understand the "dotnet new" functionality while making something real.
Here's some of the features the interns used, in their words.
- Entity Framework provides an environment that makes it easy to work with relational data. In our scenario, that data comes in the form of blog posts and comments for each post.
- The usage of LINQ (Language Integrated Query) enables the developer to store (query) items from the blog into a variety of targets like databases, xml documents (currently in use), and in-memory objects without having to redesign how things are queried, but rather where they are stored.
- The blog is built on Razor Pages from ASP.NET Core. Because of this, developers with some knowledge of ASP.NET Core can learn about the pros and cons of building with Razor Pages as opposed to the previously established MVC schema.
- The template includes a user authentication feature, done by implementing the new ASP.NET Identity Library for Razor Pages. This was a simple tool to add that consisted of installing the NuGet package and creating a new project with the package and then transferring the previous project files into this new project with Identity. Although a hassle, moving the files from one project to the other was quite simple because both projects were built with Razor Pages.
- Customizing the theme is fast and flexible with the use of Bootstrap. Simply download a Bootstrap theme.min.css file and add it to the CSS folder in your project (wwwroot > css). You can find free or paid Bootstrap themes at websites such as bootswatch.com. You can delete our default theme file, journal-bootstrap.min.css, to remove the default theming. Run your project, and you'll see that the style of your blog has changed instantly.
I wouldn't say it's perfect or even production ready, but it's a great 0.1 start for the interns and an interesting codebase to read and improve!
Here's some ideas if you want a learning exercise!
- Make the serializers swappable. Can you change XML to JSON or Markdown?
- Make an RSS endpoint!
- Add Captcha/reCaptcha
- Add social buttons and sharing
- Add Google AMP support (or don't because AMP sucks)
- Add Twitter card support
You can also just play with their running instance here. Be nice. https://venusblog.azurewebsites.net/ (Username: firstname.lastname@example.org, Password: Password.1)
Sponsor: A third of teams don’t version control their database. Connect your database to your version control system with SQL Source Control and find out who made changes, what they did, and why. Learn more!