13.2: SSL
Add SSL for Release Builds
SSL (Secure Sockets Layer) is a security technology that encrypts communication between a web browser and a server, using HTTPS (HTTP Secure) instead of HTTP (Hypertext Transfer Protocol). Here we will set the app up to require HTTPS unless we are in debug mode.
Open ElevenNote.Web -> Controllers -> AccountController
Add this annotation above the routes.
namespace ElevenNote.Web.Controllers { #if !DEBUG [RequireHttps] #endif [Authorize] public class AccountController : Controller
This code includes what are called
#if
and#endif
preprocessor directives. These act essentially like a standard if statement but are used for determining some things at the beginning of compiling the code instead of while running it. An#if
directive must always be followed at some point by an#endif
. Here's the Microsoft documentation on preprocessor directives in C#, if you're interested.Change the tab from Debug to Release. Notice the code is commented/un-commented depending on the setting.
Set the drop-down back to Debug and
Next, we'll set up the WebAPI project.
Last updated