Reputation: 1896
I am creating a line chart in one view(myChartView) and saving it as _ChartFiles/chart01.jpg. var filePathName = "_ChartFiles/chart01.jpg";
Which is saving at /views/myChartView/_ChartFiles/chart01.jpg . Now in the very next line making a reference it as
<img src="@filePathName" />
but this is not displaying the image. what would be correct way to refer it?
Upvotes: 0
Views: 51
Reputation: 1580
//try this one
filePathName = "myChartView/_ChartFiles/chart01.jpg";
<img src="@filePathName" />
Upvotes: 0
Reputation: 102
Try giving the image path as
filePathName = "../views/myChartView/_ChartFiles/chart01.jpg";
or
filePathName = "~/views/myChartView/_ChartFiles/chart01.jpg";
Upvotes: 0
Reputation: 177
You should save it in another folder than "Views" because in MVC this is a folder conventionned for HTML view and no other content, try to save it in "fonts" or whatever else, and it would be :
<img src="fonts/yourimage.jpg" />
Upvotes: 0
Reputation: 49095
If you want some static files to be accessed directly by the client, you cannot store them in the ~/Views
folder because by default (for security reasons) the server would not serve content from this folder.
See ~/Views/Web.Config
:
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
Try to save the files in other directory like ~/Static
.
Upvotes: 1