Open Closed

Widgets work in debug mode but do not working once deployed #1655


User avatar
0
Tony_Albutt created
  • ABP Framework version: v4.3.3

  • UI type: MVCr

  • DB provider: EF CoreB

  • Tiered (MVC): yes

  • Exception message and stack trace:

  • Returned 500 error

  • Below is from the loge file.

  • 2021-08-03 15:05:09.606 +02:00 [INF] Executed page /TravelRequests/Details in 1867.9162ms 2021-08-03 15:05:09.606 +02:00 [INF] Executed endpoint '/TravelRequests/Details' 2021-08-03 15:05:09.607 +02:00 [ERR] An unhandled exception has occurred while executing the request. System.InvalidOperationException: The view 'Components/TravelCostsWidget/Default' was not found. The following locations were searched: /Pages/TravelRequests/Components/TravelCostsWidget/Default.en.cshtml /Pages/TravelRequests/Components/TravelCostsWidget/Default.cshtml /Pages/Components/TravelCostsWidget/Default.en.cshtml /Pages/Components/TravelCostsWidget/Default.cshtml /Pages/Shared/Components/TravelCostsWidget/Default.en.cshtml /Pages/Shared/Components/TravelCostsWidget/Default.cshtml /Views/Shared/Components/TravelCostsWidget/Default.en.cshtml /Views/Shared/Components/TravelCostsWidget/Default.cshtml at Microsoft.AspNetCore.Mvc.ViewEngines.ViewEngineResult.EnsureSuccessful(IEnumerable1 originalLocations) at Microsoft.AspNetCore.Mvc.ViewComponents.ViewViewComponentResult.ExecuteAsync(ViewComponentContext context) at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentInvoker.InvokeAsync(ViewComponentContext context) at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentHelper.InvokeCoreAsync(ViewComponentDescriptor descriptor, Object arguments) at Volo.Abp.AspNetCore.Mvc.UI.Widgets.AbpViewComponentHelper.InvokeWidgetAsync(Object arguments, WidgetDefinition widget) at Volo.Abp.AspNetCore.Mvc.UI.Widgets.AbpViewComponentHelper.InvokeAsync(String name, Object arguments) at AspNetCore.Pages_TravelRequests_Details.<ExecuteAsync>b__94_132() in C:\Users\Anthony\source\repos\ITX_New\ITX\aspnet-core\src\ITX.Web\Pages\TravelRequests\Details.cshtml:line 444 at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.GetChildContentAsync(Boolean useCachedResult, HtmlEncoder encoder) at Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Tab.AbpTabTagHelperService.ProcessAsync(TagHelperContext context, TagHelperOutput output) at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.<RunAsync>g__Awaited|0_0(Task task, TagHelperExecutionContext executionContext, Int32 i, Int32 count) at AspNetCore.Pages_TravelRequests_Details.<ExecuteAsync>b__94_51() at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.GetChildContentAsync(Boolean useCachedResult, HtmlEncoder encoder) at Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Tab.AbpTabDropdownTagHelperService.ProcessAsync(TagHelperContext context, TagHelperOutput output) at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.<RunAsync>g__Awaited|0_0(Task task, TagHelperExecutionContext executionContext, Int32 i, Int32 count) at AspNetCore.Pages_TravelRequests_Details.<ExecuteAsync>b__94_45() at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.GetChildContentAsync(Boolean useCachedResult, HtmlEncoder encoder) at Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Tab.AbpTabsTagHelperService.ProcessAsync(TagHelperContext context, TagHelperOutput output) at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.<RunAsync>g__Awaited|0_0(Task task, TagHelperExecutionContext executionContext, Int32 i, Int32 count) at AspNetCore.Pages_TravelRequests_Details.<ExecuteAsync>b__94_3() at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.SetOutputContentAsync() at AspNetCore.Pages_TravelRequests_Details.ExecuteAsync() in C:\Users\Anthony\source\repos\ITX_New\ITX\aspnet-core\src\ITX.Web\Pages\TravelRequests\Details.cshtml:line 22 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.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|29_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeResultFilters>g__Awaited|27_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_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>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) 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 Volo.Abp.AspNetCore.Serilog.AbpSerilogMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext() --- End of stack trace from previous location --- at Volo.Abp.AspNetCore.Auditing.AbpAuditingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext() --- End of stack trace from previous location --- at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events, IBackChannelLogoutService backChannelLogoutService) at IdentityServer4.Hosting.MutualTlsEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context) at Volo.Abp.AspNetCore.Uow.AbpUnitOfWorkMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext() --- End of stack trace from previous location --- at Volo.Abp.AspNetCore.ExceptionHandling.AbpExceptionHandlingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Volo.Abp.AspNetCore.ExceptionHandling.AbpExceptionHandlingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext() --- End of stack trace from previous location --- at Volo.Abp.AspNetCore.MultiTenancy.MultiTenancyMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Builder.ApplicationBuilderAbpJwtTokenMiddlewareExtension.<>c__DisplayClass0_0.<<UseJwtTokenMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Volo.Abp.AspNetCore.Tracing.AbpCorrelationIdMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task) 2021-08-03 15:05:09.616 +02:00 [INF] Executing endpoint 'Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Controllers.ErrorController.Index (Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared)' 2021-08-03 15:05:09.616 +02:00 [INF] Route matched with {action = "Index", controller = "Error", area = "", page = ""}. Executing controller action with signature System.Threading.Tasks.Task1[Microsoft.AspNetCore.Mvc.IActionResult] Index(Int32) on controller Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Controllers.ErrorController (Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared). 2021-08-03 15:05:09.617 +02:00 [INF] Executing ViewResult, running view ~/Views/Error/500.cshtml. 2021-08-03 15:05:09.628 +02:00 [INF] Bundling __bundles/A28A764CBD2BA2A0A12B2E84D0BBCF6E.0C4EDBE702C62503400CDB0114F9D00A.css (2 files) 2021-08-03 15:05:09.635 +02:00 [INF] > Minified /Pages/Shared/Components/css/Default.css (10010 bytes -> 6559 bytes) 2021-08-03 15:05:09.639 +02:00 [INF] > Minified /Pages/Shared/Components/TravelCostsWidget/Default.css (799 bytes -> 470 bytes) 2021-08-03 15:05:09.639 +02:00 [INF] Bundled __bundles/A28A764CBD2BA2A0A12B2E84D0BBCF6E.0C4EDBE702C62503400CDB0114F9D00A.css (7029 bytes)

  • Steps to reproduce the issue:"

  • Create a widget and add it to a details page.

  • Works in debug mode

  • Does not work when deployed to local IIS server not a hosted server.

  • Code to follow


5 Answer(s)
  • User Avatar
    0
    Tony_Albutt created

    This is the widget location /Pages/Shared/Components/TravelCostsWidget/Default.cshtml The same location that is reported in the log file above indicating could not be found

    	TravelRequests/Details.schtml
        <form method="get" id="TravelCostsFilterForm">
                        <abp-input asp-for="TravelRequestId" />
                        <abp-row>
                            <div class="row" style="padding-left:24px;padding-bottom:12px;">
                                <abp-button style="float: right;" id="RefreshTravelCostsButton"
                                            text="@L["Refresh"].Value"
                                            icon="refresh"
                                            button-type="Primary"
                                            type="Submit" />
                            </div>
                        </abp-row>
                    </form>
                    <div id="TravelCostsWidgetArea" data-widget-filter="#TravelCostsFilterForm">
                        @await Component.InvokeAsync("TravelCostsWidget", new { travelRequestId = Model.TravelRequestId })
                    </div>
    
    	TravelCostsWidgetController.cs	
        namespace ITX.Web.Pages.Shared.Components.TravelCostsWidget
    		{
    		    [Route("TravelRequests/Widgets")]
    		    public class TravelCostsWidgetController : AbpController
    		    {
    		
    		        [HttpGet]
    		        [Route("RefreshTravelCosts")]
    		        public IActionResult RefreshTravelCosts(Guid travelRequestId)
    		        {
    		            return ViewComponent("TravelCostsWidget", new { travelRequestId });
    		        }
    		    }
    		}
            
            
    	TravelCostsViewModel.cs	
        namespace ITX.Web.Pages.Shared.Components.TravelCosts
    		{
    		    public class TravelCostsViewModel
    		    {
    		        public List<TravelCostDto> TravelCosts { get; set; }
    		    }
    		}
    	
        
        TravelCostsWidgetViewComponent.cs	
        namespace ITX.Web.Pages.Shared.Components.TravelCosts
    		{
    		    [Widget(
    		    StyleFiles = new[] { "/Pages/Shared/Components/TravelCostsWidget/Default.css" },
    		    ScriptFiles = new[] { "/Pages/Shared/Components/TravelCostsWidget/Default.js" },
    		    RefreshUrl = "Widgets/RefreshTravelCosts",
    		    AutoInitialize = true
    		    )]
    		    public class TravelCostsWidgetViewComponent : AbpViewComponent
    		    {
    		        private readonly ITravelCostsAppService _travelCostsAppService;
    		
    		        public TravelCostsWidgetViewComponent(ITravelCostsAppService travelCostsAppService)
    		        {
    		            _travelCostsAppService = travelCostsAppService;
    		        }
    		
    		        public IViewComponentResult Invoke(Guid travelRequestId)
    		        {
                        List<TravelCostDto> travelCosts = new();
                        if (travelRequestId != Guid.Empty)
                        {
                            travelCosts = _travelCostsAppService.GetTravelCostsForTravelRequest(travelRequestId);
                        }
                        return View(new TravelCostsViewModel { TravelCosts = travelCosts });
    		        }
    		    }
    		}
    	
        
        Default.js	
        $(function () {
    		    var myWidgetManager = new abp.WidgetManager('#TravelCostsWidgetArea');
    		    myWidgetManager.init();
    		})
    	
        
        Default.cshtml	
        @using System.Globalization
    		@using ITX.Localization
    		@using Microsoft.AspNetCore.Mvc.Localization
    		@model ITX.Web.Pages.Shared.Components.TravelCosts.TravelCostsViewModel
    		@inject IHtmlLocalizer<ITXResource> L
    		@{
    		    decimal Total = 0.00m;
    		
    		}
    		
    		<table class="table table-striped">
    		    <thead>
    		        <tr class="line">
    		            <td><strong>#</strong></td>
    		            <td class="text-left"><strong>@L["Description"]</strong></td>
    		            <td class="text-center"><strong>@L["Qty"]</strong></td>
    		            <td class="text-right"><strong>@L["Price"]</strong></td>
    		            <td class="text-right"><strong>@L["Total"]</strong></td>
    		        </tr>
    		    </thead>
    		    <tbody>
    		        @foreach (var item in Model.TravelCosts)
    		        {
    		            <tr>
    		                <td>@item.ItemNumber</td>
    		                <td class="text-left">@item.Description</td>
    		                <td class="text-center">@item.Qty</td>
    		                <td class="text-center">@item.Price</td>
    		                <td class="text-right">@item.Total</td>
    		            </tr>
    		            {
    		                Total = Total + item.Total;
    		            }
    		        }
    		            <tr>
    		                <td colspan="3">
    		                </td>
    		                <td class="text-right"><strong>Total</strong></td>
    		                <td class="text-right"><strong>@Total</strong></td>
    		            </tr>
    		        </tbody>
    		</table>
    
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi Tony_Albutt

    Can you share a minimum project? liming.ma@volosoft.com

  • User Avatar
    0
    Tony_Albutt created

    I may have found a problem. First widget is longer reporting an error. Next one is still reporting a problem

    Solution for first problem is as follows

    1. Widget folder is TravelCostsWidget.
    2. Controller name space is namespace ITX.Web.Pages.Shared.Components.TravelCostsWidget
    3. ViewComponent name space is ITX.Web.Pages.Shared.Components.TravelCosts
    4. ViewModel name space is TX.Web.Pages.Shared.Components.TravelCosts

    Solved first Widget error by renaming name space from TravelCosts to TravelCostsWidget

    I will update again later

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    👍

  • User Avatar
    0
    Tony_Albutt created

    All widgets are now working. The second widget had the same problem, but kept reporting the error. Deleted widget and re-created, and still reported the problem. Remed out all UI on Default.chtml and then workerd. Re-enabled UI and then worked ??? A referance may have been cached someware.

    All good

    Thanks

Made with ❤️ on ABP v9.1.0-preview. Updated on November 01, 2024, 05:35