Get Absolute Server Path Of Resources In ASP.NET MVC
In a scenario where you want to load images or other resources, Url.Content() does
not return the exact resource path like this (D:\Cart\CartProject\Images\Item4.jpg). Hence, resulting into a null exception or empty resource.
Instead of using Url.Content() or ResolveUrl(), i get the server path of the resource using HttpContext of the application.
Note: Testing is done locally and not on a virtual directory...
Source: Find Absolute Path the the App Data Folder from Controller Cheers!
Instead of using Url.Content() or ResolveUrl(), i get the server path of the resource using HttpContext of the application.
return new ImageResult(HttpContext.Server.MapPath("~/Images/Item" + id + ".jpg"));
Source: Find Absolute Path the the App Data Folder from Controller Cheers!
Comments
Post a Comment