asp .net mvc showing an image from local computer in view - html

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..

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.

Related

ASP not running in .htm file in browser

I am attempting to run some asp code in a htm file however whenever I open the file it doesn't actually run the code but instead just displays the code without the '<%%>'. I've tried changing the file type to all sorts of things (.html, .asp, .aspx, .shtml) however none change anything and .asp doesn't even run (instead just displays the text as the the browser would when opening a text document).
I found some code on w3schools.com which is where I'm learning html however it doesn't work nor does the site mention any prerequisites for using asp code in an htm file.
The code:
<!DOCTYPE html>
<html>
<body>
<% response.write(request.querystring("fname")) %>
</body>
</html>
I have gone and ticked the ASP Windows features and whatever else related but that did nothing.
I am on a Windows 10, if that is relevant.
I am using opera (though I've tried opening in Window's Edge as well) and just opening via double-click or dragging into window. I am new to html in general so sorry for such a dumb question that may have already been answered before, I have searched a lot but after quite some time I decided to just ask.
I'm not sure what you are learning, but I think you might have come across Classic Asp. I'd recommend you download Visual Studio Community Version which you can find here
and instead try to learn ASP.NET.
However, if you want to launch your file you will need to use the local IIS. Simply go to START and in the search bar type IIS:
It should look like this:
On the left hand site, you will see SITES --> Right Click On it and point it to your Folder/File. Once it's there, then click on your SITE Folder in IIS and click on START which is on the right side with a red border. If it doesn't come up, click BROWSE *.443 which is right below it. It should launch.
If you are just starting, I'd suggest you download Visual Studio Code or ATOM and start creating simple .html files/website. It might be too overwhelming to go into ASP.NET or Classic before you become familiar with static .Html files.

Finding unused image files from web server

recently I have a task. There are many image files (of format .jpg/.gif) uploaded to a web server. However, actually not all image in the web server is shown on the real web site. Now I want to list out the image files that is not on the web site but in the web server, so I want to find a tool that can generate a list of images of a web site, I have found a firefox extention call Link Gopher which may help to generate all links from a web page, but since the web site has many pages, I must do the task page by page if I use Link Gopher.
As a result, I want to know is there any method that can do the task faster?

Some weebly features don't work when exporting to HTML and hosting on a different server

Recently I've been tasked with redesigning a website for the current company I'm working at. I've been using weebly to make the site, and then exporting the HTML to be re-hosted on the company's servers.
However, I've noticed that some functionality in weebly's code has stopped working. I imagine this might be due to weebly hosting some elements on their own servers, but this is merely a beginners best guess.
1. The picture for the logo on the banner does not appear once the HTML is rehosted
For comparison, here's the site while hosted on weebly:
http://mjmacoustique.weebly.com/
and the site on the company's servers:
http://www.mjm.qc.ca/redesign2015/
When weebly hosts, the ''MJM'' image should be on the top left and function as a return to home page button when clicked. However, when it's hosted on the company's server, the image is not found.
2. On Firefox, the background image of the home page is replaced with an all black background
When opened in firefox, it fails to load the background image of the main page.
Any help or solutions to these problems would be greatly appreciated.
Thanks.
I can help with question #1: the logo is hosted on weebly's servers, but in the html it's written in a shortcut method like this example: /uploads/2/6/8/5/26851316/1434298489.png"
the easy workaround would be to keep the weebly version of the site working, in in the html change the src value of the missing images to something like this http://mjmacoustique.weebly.com/uploads/2/6/8/5/26851316/1434298489.png
So you haveto add the http://YOURSITE.weebly.com before all the src values of your images.
otherwise, just load all the images you need on a blank page of the site on your servers, copy image urls of those and replace the urls in the html with that.
Hope that helps?
The firefox issue might also be solved if all your src values are linked correctly but I cannot be sure about that.
When I tried exporting a site from weebly, some assets were missing from the zip it produced. This resulted in some images failing to appear because they simply weren't there. I don't know how often this happens (or if it happens only for some sites), but weebly's export feature definitely seems to have bugs.
I worked around this by using wget to recursively fetch the content that weebly was hosting. Then I hand-copied the missing assets (and only the missing assets) from the directory structure saved by wget and merged them into the directory structure from weebly's export zip. This is time-consuming, but necessary since the directory structure fetched by wget includes dynamically-generated content (meta data for weebly's editor, assets with decorated names, etc) that you probably don't want in the content you host elsewhere.

Downloading the souce of a reddit thread to save locally. The HTML is the same but the page display is all messed up

I'm downloading one page from reddit and saving it locally:
http://www.reddit.com/r/TheRedPill/comments/2uomrv/meta_sjws_are_reportedly_working_with_admins_to/
The HTML is identical in my test.html file, but when I open the local file in a browser, the page display is all messed up. Right Nav disappears, etc.
Normally I'd assume this is a CSS issue (and it definitely could be) but there are only three CSS files in the document, and they are all hosted remotely on www.redditstatic.com -- so they should still be working, right?
Is there something else I'm missing? Is redditstatic somehow smart enough to not serve CSS when I request it from my local machine?
What else could be causing the display issues? How should I troubleshoot?
Reddit uses external CSS, JavaScript, etc. to make it look as feel as it is. The website won't function correctly unless you download them all, even locally because the HTML doesn't know where to find the called file.

Can we run simple html file on our machine by turning off IIS server?

This is a very basic question but wanted to confirm that if we have a simple html file which we want to run on browser, Do we need to turn on IIS server or simple html file does not need any server and browser takes care of it?
Thank you
HP
Not sure what you mean by "run", but you can load any HTML file locally by opening it in the browser.
All javascript and HTML will work as expected, no serverside code will though.
If your links are relative links, they will also work as expected.