Working with images and other files in ASP.NET MVC 4 - asp.net-mvc-4

I know this topic is widely discussed but I can not find even partial answer that works for me.
So I'm working on a ASP.NET MVC 4 application. For testing purposes I want to use images from my local machine. In my view I have:
<div class ="banner-top" style="width: 200px; height: 200px;">
<img src='file:///C|:/Users/My-Pc/Desktop/Images/banner-big-top.png' alt="banner"/>
</div>
This is only one of the many attempts I made while trying to display this image. I can see a plain text banner and that's all. I tried forward slash, black slash, and I don't remember what else but neither was working and my setup is absolutely simple - the solution is on my local machine, the file is on the local machine. So how can I display this image? Could it be that MVC 4 itself is preventing the image from showing? I tried everything in FF and Chrome, all the different ways didn't work on both browsers.

Assuming your images are in your project, you would do:
<img src="#Url.Content("~/content/images/banner-big-top")" alt="banner" />

Based on the path you listed in the question, it looks like the images are not inside of the website. Why not move them into the website and access them via the website root path?
If moving the files into the website isn't an option, then look at this:
How to display images on a page when images are stored outside of web root

Related

How to preview a static site?

With Ruby on Rails I can run rails s -p 3000 and preview my site at localhost:3000.
With React I can run npm start and view the site at localhost:8080.
What if I just have html and CSS files, how do I preview that?
On OSX, you can run a simple web server from any directory using this command:
python -m SimpleHTTPServer 8000
Then, you can hit the directory in your browser by going to http://localhost:8000/path/to/file.html
You can try click 2 times in index.html to open the file in browser.
Every time you update the code in sublime text, you need to reload the browser and the updates will be aplied.
This usually depends on your device/OS and what your eventual goals are, but usually you can either use (online) software that renders the HTML and the CSS for you (such as Brackets.io, etc.) whilst you are typing it (to live preview any modifications/additions), or you can put the documents live using a local webserver such as Xampp or OSXs built in simple web server, and check their respective localhost locations every time you save changes using your code editor.
You could also simply use online applications like Codepen, which can also render HTML and CSS, and even JavaScript. Codepen just today launched Codepen Projects which allows you to create entire website projects at their website. It is however, a pro (paid) feature.
Here's a short overview of code playgrounds that offer the functionality you requested (by no means an exhaustive list):
JSFiddle
CSSDeck
CodePen
JSBin
And ofcourse you can insert Snippets here on StackOverflow, which is also able to render HTML and CSS (and JS).
If you really only use HTML and CSS, previewing in a browser is also possible, opening the .html file by double clicking and opening in Internet Explorer, Chrome, etc.

Including Images in RenderPDF in Play Framework

I use Play framework 1.2.x
I use PDF module renderPDF to generate PDF from HTML. I would like insert a image into the PDF.
Im trying to download image from controller downloading in the HTML which will be render as PDF as like this
<img src="#{AwardController.getSignature()}">
From the forums I found that we need to define play.pool in application.conf, So I defined it and works well in local environment. But It doesn't work in QA or Prod environment where we have two processors, so I thought it would take nbprocessors+1. I tried both defining play.pool and not defining. But there is no luck in QA/Prod environment. Please help me to resolve
UPDATE: It working when http request, but not works in https request. Do we have any settings anywhere to resolved this

Path problems with running a sub application (umbraco) inside my MVC4 web application

I have this MVC4 web application, I run it locally at mySite.local/. I created an application in IIS 7, mapping to mySite.local/corporateSite/. I point that application to an Umbraco (CMS) installation I have locally.
This works pretty well.
I have these UI images and .css files that were in my corporate site and were linked-to by absolute urls (Examples: /css/myCss.css, /media/ui/myFunLogo.png, etc.).
Now this "/" root has changed, if I want my css and images to work, I have to use /corporateSite/cssmyCss.css... this is logical.
How can I change my configuration or sites setup or code so that I don't have to write that whenever I'm linking to a file like that. Should I use rewrite rules to prepend the application url?
How to people integrate these elements normally ? I know a lot go through subdomains, but this would not be ideal for us at the moment.
Thanks for the help!
(I think my question is related to this one how to integrate umbraco with mvc4 but in some different aspects. And the answers are not good for me.)
In umbracoSettings.config, there is a setting for "ResolveUrlsFromTextString".
Setting it to true should tell Umbraco to add the virtual directory name to links and images.

Caching issue with LESS.js when used with Initializr

I am about to start a new project that requires a responsive design solution and I'd also like to take advantage of LESS.js for the styling.
I downloaded the Responsive template from Initializr and set it up as a new site on my localhost. I have begun making minor tweaks to the index.html file to begin styling the page up as it would be required for my project. I began by adjusting the width of the .wrapper class and was frustrated when my changes did not appear to be making any difference when viewing in the browser.
However upon changing the name of the folder containing the files and amending the URL, my changes appear, so there is obviously some sort of caching issue when using LESS on Localhost.
Does anyone know of a solution to this?
What worked for me was disabling, or deleting, cookies of the domain on which you're developing.

Apache not loading CSS files on remote browsers but works on localhost

I have an ubuntu installation on my laptop i use for web app development. When i type in http://localhost/blah.php i see my php web page as i normally would with all css style loaded and rendering fine.
When i try to connect to this same apache server from a remote machine by typing in the IP address the page loads but without any css styling at all. I also get the same problem trying to connect to the apache server from a virtual machine on the same box. I would like to get this working so i can test my web apps in IE but obviously css not loading is a problem. Any tips ?
Look into your source code and look how your style sheets are referenced.
If you have references to http://localhost/mystylesheet.css, that's your problem right there.
If that doesn't help, try to access a style sheet directly (enter the address in the browser) and tell us what happens. Also post the URL you are using. The head of the HTML document you are calling would also be helpful.