Get Content Folder Images In Areas Admin View ASP.NET MVC - asp.net-mvc

I want To get Images in Project/Areas/Admin/Index ..
and images in Project/Content Folder
so it show error when i use
<img src="#item.ProductImagePath" />
error
GET https://localhost:44378/Admin/Home/Content/dress3.jpg ERROR..
it find image on Admin but images are in content folder
It Added Admin in Image Path
here the image of directory and img tag

I think you use wrong routes.
for example, this image in admin areas and you can see it:
https://take-car.ru/areas/admin/MxPBksiUmnA.jpg

Related

How to create a direct link to an image for other applications to access in Rails 5.2

I am customizing the checkout page on PayPal.
To provide a logo and header image they require a URL that links directly to the image of the logo or header image such as https://some.domain.name/logo.png. I have to enter this URL on PayPal's website so that it can grab the image from my website to put on their checkout form.
I've tried placing the logo under the public directory and providing the URL: https://some.domain.name/logo.png
But this just gives a no route error.
How can I do this in Rails?
You need to put your images in your app/assets/images folder because Rails uses asset pipeline. Then you can use image_url helper to get a full url, ex:
ActionController::Base.helpers.image_url("logo.png")
I don't know what do you mean by direct link the rails way provided the functionalities for get the image link like
image_tag("rails.png")
# => <img alt="Rails" src="http://some.example.com/assets/rails.png" />
put the image on the app/assets/
also, put the direct static way like
<img alt="Rails" src="app/assets/rails.png" />
Here the doc
Hope it helps

How to use images on the error pages(404, 500 ...)?

How to use images on the error pages(404, 500 ...)?
Can I use images from a folder "assets" ?
I need to compile them or no?
You can create an image folder within the public folder, in the root of your application, and then from there, you can access them by referencing it directly.
An example on the 404 html file.
<div class="dialog">
<div>
<h1>The page you were looking for doesn't exist.</h1>
<p>You may have mistyped the address or the page may have moved.</p>
</div>
<p>If you are the application owner check the logs for more information.</p>
<img src="images/01.jpg" alt="">
</div>
public/images/ contains the 01.jpg image file.
Another idea that you could consider is having the 404.html and 500.html located on Amazon S3. Something like that would accomplish you having your picture(s) available on S3 with the entire page itself.
Then if you are using a service like Heroku to host your application, you can change the ERROR_PAGE_URL variable to point to your error page on S3.
If you can't or don't want to store the images anywhere else, you can use Base64 encoding to have the images inside the HTML code of the error page itself. You can use any Base64 encoder such as https://base64.guru/converter/encode/image

Images not rendering in localhost

I have images sitting within my project root at Data\Images\articles. I am trying to render the image using the code below in MVC:
<img src="#Url.Content(Model.Image)" alt="Image" />
It's not displaying the image, however the rendered html code is correct.
<img src="/Data/Images/Articles/16fd7bc5-3bac-474a-a806-b8d72b974960.PNG" alt="Image">
I am running the project from Visual studio server, not through IIS. Any idea what I am doing wrong here?
Different file name was generating as compare to what was expecting in logic causing 404 error when validating the image file name

Using AutoFileName with Sublime Text 2

I have installed the package 'AutoFileName' but when I try to define an img source I recieve only tag options and not images. Does anyone know if I have to define the folder where my images are or where AutoFileName looks for images?
AutoFileName lists files based on the html file you edit. For example, if test1.img, test2.img and test.html are in the same folder, it will list test1.img and test2.img if you are trying to add <img src=""> in test.html.

Where do you store images for asp.net mvc projects and how do you reference them from site.master

I have a new asp.net mvc project and i am trying to figure out the best place to store images and also how i would reference them from site.master (in cases where i have a header images that i want to show up on all pages).
Suggestions or best practices?
What I generally do is create an "Images" folder inside my Content folder. Where you place your images is really up to you, as long as you are consistent.
Referencing these images from your Site.Master is the same as if you referenced it from any view:
<img src="/Content/Images/mylogo.png" />
<img src="#Url.Content("~/Content/Images/logo.png")" />
Using this in a Razor view on MVC 5. Images are stored in /Content/Images.
<%=Html.Image("~/Content/Images/xxx.png")%>
This resolves from wherever you are in the site hierarchy. Html.Image is a part of the the Microsoft.Web.Mvc futures assembly.
or in mvc2:
<img src="<%: Url.Content("~/Images2/landingMain/safety.png") %>" alt="safety" />
U must put all your images in Content Folder like :-
Content-->Images-->.IMG files and
same as style sheet files
Content Folder like Content-->.css hence it easily load the images and css otherwise it is not executed in proper manner.

Resources