【发布时间】:2018-12-17 09:12:04
【问题描述】:
我对 Web 开发还很陌生,所以我一直在尝试使用 Microsoft 通过其默认 .NET Core 应用程序选项提供的模板代码。我能够使用 Azure 服务成功部署网站并将其连接到具有自己数据库的服务器。
然而,我一直在努力解决的一件事是设置 Facebook 身份验证。我遵循了这个指南:https://www.c-sharpcorner.com/article/authentication-using-facebook-in-asp-net-core-2-0/ 并且能够在本地成功登录 Facebook,但是当我尝试使用 ConfigureServices 函数中的新代码发布并访问网站时,我收到 HTTP 500 错误。
我的网站是:vincecoreapp.azurewebsites.net
这是我插入的sn-p:
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.AddAuthentication().AddFacebook(facebookOptions =>
{
facebookOptions.AppId = Configuration["Authentication:Facebook:AppId"];
facebookOptions.AppSecret = Configuration["Authentication:Facebook:AppSecret"];
});
// Add application services.
services.AddTransient<IEmailSender, EmailSender>();
services.AddMvc();
}
任何建议都会非常有帮助,谢谢!
【问题讨论】:
-
500 错误是没有意义的。您需要获取正在引发的实际异常,包括堆栈跟踪。使用日志记录,或者,如果此站点尚未上线,您可以暂时将
ASPNETCORE_ENVIRONMENT设置为“开发”,以允许显示开发人员异常页面。
标签: c# asp.net-core