hi
how to resolve file path reference to a file in asp.net mvc. Suppose I have an image file in the content/image/img.jpg”. How do i get the physical path of the file in asp.net mvc.
hi how to resolve file path reference to a file in asp.net mvc. Suppose
Share
You could use the MapPath method:
and if you are inside a view you don’t need the physical path but a relative path taking into account the virtual directory so you should be using Url helpers:
And if you are inside some other layer of the application which doesn’t have direct access to the HttpContext you shouldn’t be getting any physical path to a file, this path should be injected/passed to the corresponding layer.