.NET Documentation

Comprehensive guide to developing with the .NET platform

Web Applications

This section covers the development of web applications using the .NET ecosystem. .NET provides powerful frameworks and tools to build modern, scalable, and secure web applications.

Overview of .NET Web Development

The .NET platform offers several robust frameworks for web development, each suited for different needs:

Key Concepts in .NET Web Applications

Understanding these core concepts is crucial for building effective web applications:

Getting Started with ASP.NET Core

ASP.NET Core is the modern, cross-platform framework for building web applications with .NET. Here's a basic example of a simple web application:

Example: A Basic "Hello World" Page

You can create a new ASP.NET Core Web Application project using Visual Studio or the .NET CLI.

Consider a simple Razor Page located at Pages/Index.cshtml:


@page
@model IndexModel
@{
    ViewData["Title"] = "Home Page";
}

<div class="text-center">
    <h1 class="display-4">Welcome</h1>
    <p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
    <p>Current time: @DateTime.Now.ToString()</p>
</div>
            

The corresponding code-behind file (Pages/Index.cshtml.cs) might look like this:


using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;

namespace MyWebApp.Pages
{
    public class IndexModel : PageModel
    {
        private readonly ILogger<IndexModel> _logger;

        public IndexModel(ILogger<IndexModel> logger)
        {
            _logger = logger;
        }

        public void OnGet()
        {
            _logger.LogInformation("Index page loaded.");
        }
    }
}
            

Resources

Explore the links above for in-depth guides, tutorials, and API references to master .NET web application development.