ASP.NET Core Deployment and Hosting Essentials Quiz Quiz

This quiz explores foundational concepts of ASP.NET Core deployment and hosting, covering deployment methods, environment configuration, hosting models, and best practices. Strengthen your understanding of essential ASP.NET Core hosting and deployment strategies with these practical questions.

  1. Deployment Methods

    Which deployment method allows publishing an ASP.NET Core application along with the runtime, so it can run on any compatible machine without requiring a pre-installed runtime?

    1. Manual deployment
    2. Framework-dependent deployment
    3. Self-contained deployment
    4. Cross-platform deployment

    Explanation: A self-contained deployment publishes your application with all necessary runtime files, making it portable to environments without a pre-installed runtime. Framework-dependent deployment, in contrast, requires the target machine to have the runtime installed. Cross-platform deployment refers to compatibility, not a specific deployment style. Manual deployment is a general term, not a specific method recognized by the framework.

  2. Environment Variables

    Which environment variable is commonly used to specify the environment, such as Development or Production, for an ASP.NET Core application?

    1. NETCORE_ENV
    2. CORE_ENV
    3. ASPNETCORE_ENVIRONMENT
    4. DOTNET_ENVIRONMENT

    Explanation: The ASPNETCORE_ENVIRONMENT environment variable tells the application which environment-specific settings to load. DOTNET_ENVIRONMENT is occasionally used but not the standard for ASP.NET Core web apps. NETCORE_ENV and CORE_ENV do not exist as recognized environment variable keys for this purpose.

  3. Hosting Model

    In which hosting model does an ASP.NET Core app run within its own process and manage requests directly, typically using a reverse proxy in production?

    1. Integrated hosting
    2. Kestrel hosting
    3. Out-of-process hosting
    4. In-process hosting

    Explanation: Kestrel is the cross-platform web server for ASP.NET Core apps and is responsible for handling HTTP requests in its own process. Integrated and in-process hosting involve hosting models specific to a certain server, while out-of-process refers to scenarios where the app and web server processes are separate but does not specify the web server itself.

  4. Configuration Files

    What is the default configuration file used to define URL bindings for an ASP.NET Core application when using the built-in web server?

    1. appsettings.json
    2. launchSettings.json
    3. bindings.json
    4. web.config

    Explanation: The launchSettings.json file defines how an ASP.NET Core app should start, including URL bindings for local development with the built-in server. appsettings.json is mainly for application settings, web.config is used in another environment for web server configuration, and bindings.json is not a standard configuration file.

  5. Deployment Artifacts

    Which folder is typically produced as the output folder containing all files ready for deployment after publishing an ASP.NET Core application?

    1. output
    2. publish
    3. release
    4. deploy

    Explanation: The publish folder stores the build artifacts and dependencies needed to run the application after the publish command is executed. While 'deploy' and 'release' are common terms, they are not the default output directories. 'output' is sometimes used with other tools, but 'publish' is the standard.

  6. Reverse Proxy

    Why is it recommended to use a reverse proxy server in front of an ASP.NET Core application in production environments?

    1. To enable cross-platform deployment
    2. To disable HTTPS support
    3. To reduce application size
    4. For enhanced security and load balancing

    Explanation: A reverse proxy can add security features, manage load balancing, and handle tasks like SSL termination more effectively. Cross-platform deployment relates to development choices, not production architecture. Reducing application size is not a function of a reverse proxy. Disabling HTTPS is not a benefit and would be a security risk.

  7. Logging in Production

    When deploying an ASP.NET Core application to production, what is the best practice regarding logging?

    1. Only log debug information
    2. Disable all logging
    3. Log errors and warnings, avoid verbose logs
    4. Log everything to the console

    Explanation: In production, detailed logs can expose sensitive data or clutter storage, so typically only errors and warnings are logged. Disabling all logging means missing critical issues, and logging only debug information is more suitable for development. Logging everything to the console is inefficient and not secure for production.

  8. Application Update Strategy

    What deployment approach minimizes downtime by deploying updates to multiple servers one at a time, allowing traffic to be routed only to servers with the latest version?

    1. Hotfix deployment
    2. Rolling deployment
    3. Offline deployment
    4. Full replacement deployment

    Explanation: Rolling deployment updates servers incrementally, helping ensure high availability with minimal downtime. Full replacement would bring all servers down simultaneously. Offline deployment generally requires downtime, and hotfix deployment refers to small updates rather than a structured deployment strategy.

  9. Static Files Handling

    Which middleware enables serving static files like images, CSS, and JavaScript directly in an ASP.NET Core application?

    1. Default File Middleware
    2. Static File Middleware
    3. Session Middleware
    4. Compression Middleware

    Explanation: Static File Middleware handles serving files directly to the client without further processing. Default File Middleware assists by providing an index page if no file is specified, not serving static files itself. Compression Middleware reduces file size but does not serve files, while Session Middleware manages server-side storage for user sessions.

  10. Port Configuration

    How can you specify a custom port for your ASP.NET Core application to listen on when it starts?

    1. Change the Startup.cs class name
    2. Set the ASPNETCORE_URLS environment variable
    3. Edit the project.json file
    4. Configure the package manager

    Explanation: Specifying the ASPNETCORE_URLS environment variable instructs the app to listen on given URLs and ports. Editing project.json is outdated and no longer used for this purpose. Changing the Startup.cs class name has no impact on port settings. The package manager does not control runtime configuration.