Closed jrodenburg closed 5 years ago
I am running a dotnet core MVC service using Razor templates. Under local operation (dotnet run), the site works fine but generates NRE in a view when executed under Docker.
I'm guessing this is related to installed SDKs, but I'm following the example here: https://github.com/dotnet/dotnet-docker/tree/master/samples/aspnetapp
Dockerfile:
FROM microsoft/dotnet:2.1-sdk AS build WORKDIR /app # copy csproj and restore as distinct layers COPY *.sln . COPY admin-ui/*.csproj ./admin-ui/ COPY api-client/*.csproj ./api-client/ # api-client is a project dependency of admin-ui RUN dotnet restore # copy everything else and build app WORKDIR /app/ COPY admin-ui/. ./admin-ui/ COPY api-client/. ./api-client/ WORKDIR /app/admin-ui RUN dotnet publish -c Release -o out FROM microsoft/dotnet:2.1-aspnetcore-runtime AS runtime WORKDIR /app COPY --from=build /app/admin-ui/out . ENV ASPNETCORE_ENVIRONMENT=Production ENV ASPNETCORE_URLS http://*:3600 EXPOSE 3600/tcp ENTRYPOINT ["dotnet", "admin-ui.dll"]
Accessing a URL called "Brands", the error output:
NullReferenceException: Object reference not set to an instance of an object. admin_ui.Pages.Pages_Brands.ExecuteAsync() in Brands.cshtml Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context) Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, bool invokeViewStarts) Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context) Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, string contentType, Nullable<int> statusCode) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultAsync(IActionResult result) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResultFilterAsync<TFilter, TFilterAsync>() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.ResultNext<TFilter, TFilterAsync>(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultFilters() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync() Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Is this related to MVC, Razor, docker....?
IGNORE the error -- completely unrelated to Razor/MVC/docker.
Don't ignore the error -- an unrelated error was occurring in the stack, but this is what was reported.
I am running a dotnet core MVC service using Razor templates. Under local operation (dotnet run), the site works fine but generates NRE in a view when executed under Docker.
I'm guessing this is related to installed SDKs, but I'm following the example here: https://github.com/dotnet/dotnet-docker/tree/master/samples/aspnetapp
Dockerfile:
Accessing a URL called "Brands", the error output:
Is this related to MVC, Razor, docker....?