0

So, I have an image on my computer. I make an html-page with simple code, src="file:\\\C:\...\file.png"

It's ok, image is shown.

Then I write the same code in mvc-view. Image isn't shown, firebug shows gray img code.. I have seen some tips about Url.Content, but they didn't help..

1 Answer 1

2

If you create an HTML file on your disk and open it in a browser (with a URL such as file:///mypage.html), then it can serve images straight from your hard disk (I believe) and no Web server is involved.

But once you start using ASP.NET, then you are no longer viewing through a file URL, but through a local web server (e.g. http://localhost/mypage) and only images that are deployed on your web server can be served. That can still easily be done, drag and drop images into your Visual Studio solution.

Sign up to request clarification or add additional context in comments.

2 Comments

So you mean, that I can't make a form, that takes user's image and shows it from his local computer on next page?
Not directly--a browser won't let you access a file on the local file system from a web page (unless that page is also on the local file system). What you can do is ask the user to upload an image, then store that image somewhere, and then display that image in the next page. That's a lot more complicated but it's the only way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.