0
votes

I have deployed an ASP.NET CORE web API project on Azure app services. I have copied a file using an FTP client to /site/wwwroot. Now let suppose file name is xyz.jpg, so it should be accessible with link somename.azurewebsites.net/xyz.jpg but ITS NOT. I have tried pasting the file in other folders to but nothing works.

I also have a controller for uploading pictures. It's also working fine. It uploads the picture in desired folder, i can see the picture via FTP client but still the picture is not accessible via any link. What am I doing wrong here ?

1

1 Answers

1
votes

For a Web API application, you have to define the request and response yourself in the controller, or your link can't be recognized by the application.

For example, you can add the method to your controller. It works on my side.

    [Route("myroute/{pic}")]
    public IActionResult Get(string pic)
    {
        Byte[] b = System.IO.File.ReadAllBytes("image/"+pic);          
        return File(b, "image/jpeg");
    }

In my code, pictures are stored in the folder called image in the root directory, and I define a route called myroute.

Here's my link to access the picture.https://myappname.azurewebsites.net/myroute/mypicname.jpg Hope it helps.