+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Using MVC request image path by Controlller Action throwing 404 calling from a different View

Using MVC request image path by Controlller Action throwing 404 calling from a different View

2 posts, 0 answered
  1. Uttam
    Uttam avatar
    21 posts
    Registered:
    17 Mar 2015
    29 Jun 2015
    Link to this post

    HI,

    Using MVC request image path by Controlller Action throwing 404 calling from a different View and it works fine if I try with browser address bar. User browser developer tool I also noticed that, the request path got change and it looks like as follows and throwing a 404.

     "NetworkError: 404 Not Found - http://localhost:1929/Sitefinity/Themes?action=resizeimage&controller=UtilityController&imagefilepath=~%2Fpoi_fdrsunshinespecial.jpg"

    I'm not sure why request went through Sitefinity/Themes.

    Here is my controller code:

    public class UtilityController : Controller
        {
            public ActionResult Index()
            {            
                return Json("");
            }

            public ActionResult ResizeImage(string imageFilePath)
            {
                //here is the simple code for testing
                Image resizedImage = resizedImage = Image.FromFile(imageFilePath);
                MemoryStream ms = new MemoryStream();
                resizedImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                return File(ms.ToArray(), "image/jpeg");
            }

    }

    Here is my View code:

    <img src="@Url.Action("resizeimage", "Utility" , new { imagefilepath="~/poi_fdrsunshinespecial.jpg" })" />​

    If I call directly using web browser then it works fine:

    http://localhost:1929/utility/resizeImage/poi_fdrsunshinespecial.jpg

    Any help is very appreciated.

    Thanks.

     

     

     

     

  2. Sabrie Nedzhip
    Sabrie Nedzhip avatar
    534 posts
    Registered:
    09 Dec 2016
    02 Jul 2015
    Link to this post
    Hello Uttam,

    The issue you are experiencing seems to be related to a bug which we have logged in our portal on the following link:

    http://feedback.telerik.com/Project/153/Feedback/Details/130166-returning-fileresult-in-an-mvc-action-does-not-work

    Fortunately, the issue has been fixed in Sitefinity version 7.1.5213. So, What I can suggest is to upgrade your Sitefinity project to the latest internal build for Sitefinity 7.1 or the best option will be to upgrade directly to the latest Sitefinity version (8.0) in order to resolve the issue and get advantage of other fixes included in this release. You may refer to our upgrade documentation for more details about the supported upgrade procedure.

    Regards,
    Sabrie Nedzhip
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
2 posts, 0 answered