-1

I am upgrading a website from MVC5 to Net Core 2.1 and installing in Azure Web Apps. I want to test the website in Azure before going to production. I have setup a test website but have not purchased an SSL certificate. I am getting 404 errors for missing views on the test website but not in VS2017 development. How can I remove the requirement for an SSL certificate. The following code is in my Startup.cs.

        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            app.UseDatabaseErrorPage();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
            app.UseHsts();
        }

        app.UseHttpsRedirection();
        app.UseStaticFiles();
        app.UseCookiePolicy();

        app.UseAuthentication();

        app.UseSession();

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });

I created a test website in VS2017 without HTTPS selected. I do not see any difference between a site with Https and one without Https. Also, using the Chrome browser, the site shows as "Secure". I have never received a message for a missing SSL certificate.

Bob Neal,

  • Maybe [this](https://stackoverflow.com/questions/50935730/asp-net-core-2-1-kestrel-how-to-disable-https) SO question may help you. – Jeroen Heier Aug 27 '18 at 18:57
  • I added the UseKestrel(… code with one loopback address set to 5080. I still receive the 404 errors for missing views. In the Development version, the views are found. In the Production version, the views are missing. – Robert Neal Aug 27 '18 at 20:24
  • You should scan your code for querying the IHostingEnvironment interface; see [here](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-2.1). Are you sure nothing is excluded in production? – Jeroen Heier Aug 28 '18 at 03:47
  • I have checked all the code references to IHostingEnvironment for any effect on the production version. I used the feature in Azure Kudu to see the website. I can not figure out what was actually published. Netcore MVC is a lot different from MVC5.2. – Robert Neal Aug 28 '18 at 15:29

1 Answers1

-1

Remove app.UseHttpsRedirection(); :)

Mehdi Ibrahim
  • 2,434
  • 1
  • 13
  • 13
  • In the test website published to azure, I removed the app.UseHttpsRedirection() and still received the 404 errors for missing views. In the Development version, the views are found. In the Production version, the views are missing. – Robert Neal Aug 27 '18 at 20:21
  • You sure the 404 (not found) exceptions are related to SSL? Are you accessing the website with the http or https url? – Mehdi Ibrahim Aug 27 '18 at 20:22
  • You are correct. The 404 messages are not caused by SSL. The problem has turned out to be Httpcontext.session is not working in Production. I will post another question. Thank you for your help. – Robert Neal Aug 28 '18 at 15:24