Asp.net core 6.0 with MVC application - Unable to launch razor view which is having partial view after deploying in IIS 10 version on windows server 2016.

Prasad 20 Reputation points
2024-02-15T17:36:03.7933333+00:00

I have developed MVC web application with .net core 6.0 and I am using these technologies...

  1. Web API (Hosted on same server in IIS)
  2. Entity Framework
  3. SQL Server
  4. Razor views, JavaScript, JQuery & Bootstrap.
  5. Apexcharts

Issue : After deploying in IIS 10 on windows server 2016, I'm able to browse razor view page with very basic controls(like jquery datatable and postedFiles button) and there is no code on my controller1 index but unable to launch razor view page in which i have implemented partial view and in controller2 Index event i have added code to fetch data from API(which is hosted on same server IIS) to show in apexcharts.

Installed below exe files on windows server 2016

  1. dotnet-hosting-6.0.26-win
  2. dotnet-sdk-6.0.418-win-x64
  3. aspnetcore-runtime-6.0.23-win-x64

Package to deploy on server

  1. I have used VS2022 to develop application and i have used publish option to generate package and after publishing successfully i have copied all the files from the published folder and pasted on windows server->IIS->MyWebsite virtual directory folder.

When i try to launch the view which has partial view I'm getting below error message:

An unhandled exception occurred while processing the request.> NullReferenceException: Object reference not set to an instance of an object.> AspNetCoreGeneratedDocument.Views_Shared_Dashboard.ExecuteAsync() in Dashboard.cshtml, line 1686

The line 1686 is my partial view...

<div class="col-md-8" id="Container"> > @{> line 1686 --> await Html.RenderPartialAsync("~/Views/Shared/_Test.cshtml");> }> </div>Full ExceptionDetails

Show raw exception details> System.NullReferenceException: Object reference not set to an instance of an object.> at AspNetCoreGeneratedDocument.Views_Shared_Dashboard.ExecuteAsync() in C:\Users\name\source\repos\MVCPrj\MVCPrj-UI\Views\Shared\Dashboard.cshtml:line 1686> at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)> at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)> at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)> at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable1 statusCode)> at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable1 statusCode)> at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, String contentType, Nullable`1 statusCode)> at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)> at Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)> at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeResultAsync>g__Logged|22_0(ResourceInvoker invoker, IActionResult result)> at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0[TFilter,TFilterAsync]> at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)> at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync]> at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()> --- End of stack trace from previous location ---> at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)> at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)> at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)> at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()> --- End of stack trace from previous location ---> at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)> at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)> at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)> at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)> at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)> at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)> at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)> at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
716 questions
Internet Information Services
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,321 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,388 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,540 questions
{count} votes