5

Please, I need help with a nagging issue with an asp.net core mvc app.

The app only shows blank home page - no contents at all including html markups. No controller is invoked even by typing url directly on the browser and no error is displayed.

I've created new app all over again a couple of times with the same result. Also, I've added statements below to the Configure method in the Startup class to no avail.

app.UseDefaultFiles();
app.UseStaticFiles();
app.UseIdentity();

Any guide to resolve this mystery would be highly appreciated.

Thanks.

 public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) {
        loggerFactory.AddConsole(Configuration.GetSection("Logging"));
        loggerFactory.AddDebug();

        //add NLog to ASP.NET Core
        //loggerFactory.AddNLog();

        ////add NLog.Web
        //app.AddNLogWeb();

        //needed for non-NETSTANDARD platforms: configure nlog.config in your project root
        //env.ConfigureNLog("nlog.config");

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

        app.UseDefaultFiles();
        app.UseStaticFiles();
        app.UseIdentity();

        // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715
        app.UseMvcWithDefaultRoute();
        //app.UseMvc(routes => {
        //    routes.MapRoute(
        //        name: "default",
        //        template: "{controller=Home}/{action=Index}/{id?}");
        //});

        // For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859
        try {
            using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>()
                .CreateScope()) {
                serviceScope.ServiceProvider.GetService<ChurBaseContext>()
                     .Database.Migrate();

                var userManager = serviceScope.ServiceProvider.GetService<UserManager<ChurchMember>>();
                var roleManager = serviceScope.ServiceProvider.GetService<RoleManager<IdentityRole>>();

                serviceScope.ServiceProvider.GetService<ChurBaseContext>().EnsureSeedData(userManager, roleManager);
            }
        } catch { }
    }
0

5 Answers 5

5

I had this behavior when I setup a Use() extension in the Startup.cs, above the UseMvc(), that did not invoke "await next();" at the end of the function.

app.Use(async (context, next) =>
{
    // some custom magic

    await next();// don't forget this
});

app.UseMvc(routes =>
{
    routes.MapRoute(
        name: "default",
        template: "{controller=Home}/{action=Index}/{id?}");
});
Sign up to request clarification or add additional context in comments.

Comments

3

You can try adding, either:

app.UseStatusCodePages();

or

app.UseStatusCodePagesWithReExecute("/error/{0}");

For info on the latter you can see: [When using UseStatusCodePagesWithReExecute, statuscode is not sent to browser

Comments

0
app.UseMvcWithDefaultRoute(); //in startup.cs

or

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

1 Comment

I have everything in place as mentioned but still experiencing the same issue. Not sure what I'm doing wrong, still. Thanks.
0

This may happened because, you have not used MVC into execution pipeline.

In Configure method of startup class, you need to add like this-

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            ......

            app.UseStaticFiles();

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

or add UseMvcWithDefaultRoute like this-

app.UseMvcWithDefaultRoute();

This basically adds MVC to the IApplicationBuilder request execution pipeline.

See if this helps.

6 Comments

Also, check your browser console, you will see error like this- Failed to load resource: the server responded with a status of 404 (Not Found)
Thanks for the quick response. I've setup everything as instructed but no difference. No error in the browser console as well.
Can you share complete configure method of startup?
I just did. Thanks.
I have same issue. Everything works under Windows 10 with IISExpress, but not work on apache/centos.
|
0

When you see just a blank page and have no response other that the blank page, it can be caused by many things. These are two that I have seen:

  1. A corrupt web.config
  2. A web.config that is clashing with IIS. This could happen when a particular section is locked in your IIS configuration.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.