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.
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?
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.
Which environment variable is commonly used to specify the environment, such as Development or Production, for an ASP.NET Core application?
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.
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?
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.
What is the default configuration file used to define URL bindings for an ASP.NET Core application when using the built-in web server?
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.
Which folder is typically produced as the output folder containing all files ready for deployment after publishing an ASP.NET Core application?
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.
Why is it recommended to use a reverse proxy server in front of an ASP.NET Core application in production environments?
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.
When deploying an ASP.NET Core application to production, what is the best practice regarding logging?
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.
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?
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.
Which middleware enables serving static files like images, CSS, and JavaScript directly in an ASP.NET Core application?
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.
How can you specify a custom port for your ASP.NET Core application to listen on when it starts?
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.