I got the error when Add product video in product edit page without Embed video URL

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
1 anno tempo fa
Nop version 4.6 develop
I got the error when Add product video in product edit page without Embed video URL (and check log)
Please fix it aspe
-----------------------------------------------------------------
Exception
-----------------------------------------------------------------
System.NullReferenceException: Object reference not set to an instance of an object.
   at Nop.Web.Areas.Admin.Controllers.ProductController.ProductVideoAdd(Int32 productId, ProductVideoModel model) in C:\andrei\nopcommerce\demo_sites\sources\src\Presentation\Nop.Web\Areas\Admin\Controllers\ProductController.cs:line 1813
1 anno tempo fa
There is a work item for this.
1 anno tempo fa
Ok Mr.RomanovM 👍
1 anno tempo fa
[HttpPost]
        public virtual async Task<IActionResult> ProductVideoAdd(int productId, [Validate]
                         ProductVideoModel model)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageProducts))
                return AccessDeniedView();
            if (productId == 0)
                throw new ArgumentException();

            //try to get a product with the specified id
            var product = await _productService.GetProductByIdAsync(productId)
                ?? throw new ArgumentException("No product found with the specified id");
        
             var videoUrl = model?.VideoUrl?.TrimStart('~');

            try
            {
                if (!string.IsNullOrEmpty(model.VideoUrl))
                {
                    await PingVideoUrlAsync(videoUrl);
                }
                else
                {
                    return Json(new
                    {
                        success = false,
                        error = $"{await _localizationService.GetResourceAsync("Embed video URL is Empty")}",
                    });
                }
            }
1 anno tempo fa
I have tried to fix that and now working fine that ..........
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.