c# – Asp.Net Core 2.0 ArgumentNullException:值不能为null.
发布时间:2020-12-15 22:49:28 所属栏目:百科 来源:网络整理
导读:我在我的电脑上使用ASP.NET Core 2.0,Visual Studio 2017 Enterprise,版本15.5.4和本地数据库. 我是第一次使用数据库,我遇到了以下问题: unhandled exception occurred while processing the request. ArgumentNullException: Value cannot be null. Parame
我在我的电脑上使用ASP.NET Core 2.0,Visual Studio 2017 Enterprise,版本15.5.4和本地数据库.
我是第一次使用数据库,我遇到了以下问题:
在阅读并尝试每一个可能的建议以及可能的解决方案之后,问 public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddDbContext<VideosContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); } public void Configure(IApplicationBuilder app,IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default",template: "{controller=Home}/{action=Index}/{id?}"); }); } } { "ConnectionString": { "DefaultConnection": "Server =(localdb)mssqllocaldb;Database=Videos;Trusted_Connection=True;MultipleActiveResultSets=true" },"Logging": { "IncludeScopes": false,"LogLevel": { "Default": "Warning" } } } public static void Main(string[] args) { BuildWebHost(args).Run(); } public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .Build(); 我究竟做错了什么?提前感谢您的任何建议. 解决方法
您的应用设置JSON文件是否具有正确的语法?
{ "ConnectionStrings": { "DefaultConnection": "Server =(localdb)mssqllocaldb;Database=Videos;Trusted_Connection=True;MultipleActiveResultSets=true" } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |