首页 新闻 赞助 找找看

ASP.NET Core: 'IWebHostBuilder' does not contain a definition for 'UseApplicationBasePath'

0
悬赏园豆:10 [已解决问题] 解决于 2016-03-23 14:34

用 dotnet run 命令运行 asp.net core 程序出现下面的错误:

/git/AboutUs/Program.cs(14,26): error CS1061: 'IWebHostBuilder' does not contain a definition for 'UseApplicationBasePath' and no extension method 'UseApplicationBasePath' accepting a first argument of type 'IWebHostBuilder' could be found (are you missing a using directive or an assembly reference?)

Program.cs 的代码如下:

public class Program
{
    public static void Main(string[] args)
    {
        var host = new WebHostBuilder()
                    .UseServer("Microsoft.AspNetCore.Server.Kestrel")
                    .UseUrls("http://*:8001")
                    .UseApplicationBasePath(Directory.GetCurrentDirectory())
                    .UseDefaultConfiguration(args)
                    .UseIISPlatformHandlerUrl()
                    .UseStartup<Startup>()
                    .Build();

        host.Run();
    }
}

之前是能正常运行的。

dudu的主页 dudu | 高人七级 | 园豆:31075
提问于:2016-03-23 14:21
< >
分享
最佳答案
0

原来是 Microsoft.AspNetCore.Hosting 的 API 改了,UseApplicationBasePath() 被改名为 UseContentRoot() 。

dudu | 高人七级 |园豆:31075 | 2016-03-23 14:34

Microsoft.AspNetCore.Hosting又改名了:.UseDefaultConfiguration() 改为了 .UseDefaultHostingConfiguration()

dudu | 园豆:31075 (高人七级) | 2016-03-25 11:07
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册