0

I have a simple page where i try to load an image from the database.

The method in controller is not responding to the url.Action call.

i have a page in another area which is identical to this page and it is working fine there (I literally copy the html from the working view to this view and the method is still not invoked).

On the browser is get :

GET https://localhost:7260/admin/AdImage/MyAction?path=img%2Fjpg net::ERR_BLOCKED_BY_CLIENT

Not getting this error in the other working page.

Here is the view calling the controller method: @model Click2Lock.Models.ForCompListVM

@{ ViewData["Title"] = "Home Page"; }
<body>
    &nbsp;
   <div class="col-4" >
       <div id="imageDiv">
        <img src= '@Url.Action("MyAction", "AdImage", new{path="img/jpg"})'/> @* NOT RESPONDING *@
        </div>
       <div class="form-group row">
            <div class="col-2">
                <label asp-for="forCompList.CompId">Company</label>
             </div>
             <div class="col-8">
                   @Html.DropDownListFor(m => m.forCompList.CompId, Model.CompList,
                                                new { @class = "form-control" })
            </div>
        </div>
        <div class="col-2 text-right">
            <button class="btn btn-primary" style="background-color:forestgreen" onclick="LoadImage()">
                <i class="fa fa-refresh"></i> &nbsp; Load Company Image</button>
        </div>
    </div>
    &nbsp;
   
</body>

controller method:

[HttpGet]
        [Route("compmanager/AdImage/MyAction")]
        public FileContentResult MyAction()
        {
            byte[] img = new byte[100000];
            ApplicationUser appUser =
           _unitOfWork.ApplicationUser.GetAll().Where(a => a.UserName == User.Identity.Name).FirstOrDefault();
            if (appUser != null)
            {
                img = _unitOfWork.Company.GetAll().Where(a => a.Id == appUser.CompanyId).
                    Select(a => a.PhotoAd).FirstOrDefault();
            }
            if (img == null)
            {
                return null;
            }
            return new FileContentResult(img, "img/jpg");
        }
Kobi
  • 117
  • 2
  • 12

0 Answers0