Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

IOptions at Razor page missing reference

$
0
0

Hi,

I created a clean Core 2.0 with Authentication, but when I inject the IOptions at Razor page (Account/login), the error occurs. Nuget already reference "Microsoft.Extensions.Options (2.0.1)" when I created the project.

Error
One or more compilation references are missing. Ensure that your project is referencing 'Microsoft.NET.Sdk.Web' and the 'PreserveCompilationContext' property is not set to false.

The type or namespace name 'IOptions<>' could not be found (are you missing a using directive or an assembly reference?)

public IOptions<AppSettings> Settings { get; private set; }

View
@model LoginViewModel
@inject IOptions<AppSettings> Settings

<div>login elements here...</div>

AppSettings.cs
public class AppSettings {
public static readonly string DemoPassword = "Password";
}

Thanks


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>