ASP.NET Core 1.1 runs fine locally but when publishing to Azure says “An error occurred while starting the application.”

前端 未结 10 1164
情话喂你
情话喂你 2020-12-01 02:42

I\'ve been developing an ASP.NET Core web app, based largely on the MVC template provided in Visual Studio 2017 RC2. It runs just fine in local debug mode, but when I try to

10条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-01 03:12

    In my case, it was because I was trying to publish user secrets for use with Fabook OAuth. I know that's a very situational specific answer, but OAuth seems pretty common these day. User Secrets, it turns out, are not meant to be published. Who knew.

    So to test this I temporarily changed the following code in startup.cs. This data should be not hard coded as a part of best practice, as it would end up in clear text in source control.

    Before

        app.UseFacebookAuthentication(new FacebookOptions()
        {
            AppId = Configuration["Authentication:Facebook:AppId"],
            AppSecret = Configuration["Authentication:Facebook:AppSecret"]
        });
    

    After

        app.UseFacebookAuthentication(new FacebookOptions()
        {
            AppId = "0000000000000", // your value
            AppSecret = "0000000000000000000000000000000" // your value
        });
    

    Then it worked.

提交回复
热议问题