I want to customize the login view for Basic Authentication. I see in the docs that I can use the files at /umbraco/BasicAuthLogin/Login.cshtml. But I can’t find those files. Can anyone point me to the right location please?
Hi mate,
The files aren’t in your project. The built-in views are compiled into the Umbraco.Cms.StaticAssets package, and /umbraco/BasicAuthLogin/Login.cshtml is only the path they’re served from inside it.
1. Copy the originals from GitHub. Pick the tag that matches your Umbraco version (these links are 17.6.0):
2. Save them in your project, for example in ~/Views/BasicAuth/. Change the markup and CSS as much as you like, but keep the @model, the anti-forgery token and the form fields as they are.
3. Point Umbraco at them in appsettings.json:
"Umbraco": {
"CMS": {
"BasicAuth": {
"Enabled": true,
"RedirectToLoginPage": true,
"LoginViewPath": "~/Views/BasicAuth/Login.cshtml",
"TwoFactorViewPath": "~/Views/BasicAuth/TwoFactor.cshtml"
}
}
}
Restart the site and you’ll see your view.
Two things I found while testing this on 17.6:
- Putting a file at the same path, /umbraco/BasicAuthLogin/Login.cshtml, does not replace the built-in view with the default project template. Use the settings above.
- Files in
wwwrootload before Basic Auth runs, so your login page can use your own logo and CSS.
Awesome, thank you! That worked.