加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-core – ASP.NET核心添加视图参数名称路径不能为空错误

发布时间:2020-12-16 06:50:55 所属栏目:asp.Net 来源:网络整理
导读:我正在尝试添加视图到我的ASP.NET核心MVC项目,我收到一个错误. 错误消息是 There was an error running the selected code generator: 'Value cannot be null. Parameter name:path' 该视图将用于ViewComponent. 我的步骤是 Right click - Add View - Type V
我正在尝试添加视图到我的ASP.NET核心MVC项目,我收到一个错误.

错误消息是

There was an error running the selected code generator:
 'Value  cannot be null. 
 Parameter name:path'

该视图将用于ViewComponent.

我的步骤是

Right click -> 
 Add View -> 
 Type View Name -> 
 Uncheck 'Use a Layout Page' -> 
 Template : Empty -> 
 Click Add.

我搜索了一下,但找不到任何结果.

编辑:

这是一个Startup.cs

namespace Udemy.MvcWebUI
{
public class Startup
{
    // This method gets called by the runtime. Use this method to add 
    //services to the container.
    // For more information on how to configure your application,visit https://go.microsoft.com/fwlink/?LinkID=398940
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddScoped<IUsersService,UsersManager>();
        services.AddScoped<IUsersDAL,EFUsersDAL>();

        services.AddScoped<IUsersInfoService,UsersInfoManager>();
        services.AddScoped<IUsersInfoDAL,EFUsersInfoDAL>();

        services.AddScoped<IEventTypesService,EventTypesManager>();
        services.AddScoped<IEventTypesDAL,EFEventTypesDAL>();

        services.AddScoped<IEventsService,EventsManager>();
        services.AddScoped<IEventsDAL,EFEventsDAL>();

        services.AddScoped<ICityService,CityManager>();
        services.AddScoped<ICityDAL,EFCityDAL>();

        services.AddScoped<IDistrictService,DistrcitManager>();
        services.AddScoped<IDistrictDAL,EFDistrictDAL>();

        services.AddDbContext<EventContext>(options => options.UseSqlServer(@"Server=localhostSQLEXPRESS;Database=Events;
                                        User Id=sa;Password=Omurcan.1994;"));

        services.AddMvc();
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app,IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

        app.UseFileServer();
        app.UseNodeModules(env.ContentRootPath);
        app.UseMvcWithDefaultRoute();

        // db tanimi icin
        using (var serviceScope = app.ApplicationServices.GetService<IServiceScopeFactory>().CreateScope())
        {
            var context = serviceScope.ServiceProvider.GetRequiredService<EventContext>();
            context.Database.EnsureCreated();
        }
    }
}
}

我该如何解决?

谢谢你的帮助.

解决方法

可能是您的项目中缺少Microsoft.VisualStudio.Web.CodeGeneration.Design包!

根据您的项目.NET Core版本安装正确版本的Microsoft.VisualStudio.Web.CodeGeneration.Design nuget包.

然后,如果您最近从任何较低版本将项目更新到.NET Core 2.1,那么也将项目的包更新到最新版本.

然后不要忘记Download .NET Core SDK的最新稳定版本(2.1.500)并在您的机器上安装.

希望你的问题能够得到解决!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读