ASP.NET MVC 4 Application on IIS 8 not showing png images - asp.net

I deployed asp.net mvc 4 application on windows 2012 server today. Everything is working fine but no png images are loading.
The below are the screenshots
These are some things I checked
I can load different images in this folder except the ".png"s.
Static Content was installed on my webserver.
Check MIME types .. png are included there
Added the following code to route config
routes.IgnoreRoute("{resource}.png")
Also checked the advanced Attributes by going into the properties of the file on webserver. The below is the screenshot.

Try use this:
<img src="<%= Url.Content("~/Content/logo.png")%>" alt=""/>

Related

Can not find image path in web application

I am using asp.net mvc 4.0 application.
I am using II7/II8.
I have configured my web application under following way in IIS in following way
Default Web Site\MyWebApp
When I am trying to browser my page in local machine
http://localhost/Home in that following image is rendered. This image is surely available at /Content/Images/ but not loaded properly, when in browser I do inspect element and alter the path like /MyWebApp/Content/Images/ it is loading an image properly.
<img alt="close" style="cursor: pointer;" src="/Content/Images/ic-delete.png" onclick="closePopUp('dvclose');">
While in live server IIS , I have website like www.xxx.yzx and when I am trying to browse
www.xxx.yzx/home it is loading image properly
i am trying to do somthing so I don't want to bother to change path(remove MyWebApp) of image when I am deplying. I don't want to move my application from Default We Site
What to do for loading image in local machine?
Posting my comment as the answer:
~/Content/Images/ic-delete.png Try that as the src.

MVC CSS not rendering in Visual Studio When debugging

I have an issue where the CSS is not rendering properly when I compile the MVC project and view it on [https://localhost/MyApp.] The buttons, and background image are not showing up. It worked one time, then for some reason it stop working. Something with the pages not caching? I used firebug to check to see if the pages were missing, and no errors were found. Something in Visual Studio 2010 settings need changing or IIS?
However, when I publish it to an individual website, instead of in the (default web site) area, using [https://localhost:444] website I setup in IIS 7.5, the css seem to render fine.
What is the problem?
One common problem that occurs on MVC 4 websites is difference between release and debug when you have css bundles. It does not have to be your case, but you have the symptoms.
I will explain on an example.
If you have bundle which looks like this:
var styles = new StyleBundle("~/Content/css").Include(
"~/Content/toastr.css",
"~/Content/flags/stylesheets/flags16.css",
"~/Content/flags/stylesheets/flags32.css",
"~/Content/Site.css")
And in flags16.css you have:
background:url('flags/images/flags16.png');
Which uses file in ~Content/flags/images/flags16.png
That will work in release mode (compilation debug="false" in web.config), because all of your css files in bundle will be served as 1 file located at ~/Content/css with relative path 'flags/images/flags16.png' pointing at correct file.
However, in debug mode, ASP.NET MVC will disable minification, and if you used #Styles.Render("~/Content/css") inside your view, it will render link to every one of your files contained in a bundle, so there will be a:
<link href="/WorkOrders.Web/Content/flags/stylesheets/flags16.css" rel="stylesheet">
And from that path, relative path to image is not ok, so images in flags16.png will not be rendered.
One way to solve this, you need to move your .css file which contains references to images to the location where bundle is pointing (~/Content in this case), so it will have same path when it is served minified and raw.
UPDATE As your app is not mvc4, and you have problems when your app is not in the root of your web site (i.e. when it is in localhost/myapp) then you need to check paths in references to your pictures. It is possible that you referenced them absolutely ('/somepath/mypic.png'), and when your app is in localhost/MyApp, path needs to be localhost/MyApp/somepath/mypic.png. You can solve that by replacing path with #Url.Content(~/somepath/mypic.png), if you are using it from cshtml. If path is in css, then you need to put relative path to your pictures.
I have just been battling with the same problem - images, scripts and css not being found or rendered. (Visual Studio 2013, Windows 8.1. Project moved across from Visual Studio 2010.)
The problem was caused by a line in Web.config:
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
It seems that because the IIS Express application.host file already contained this mimeMap definition, IIS Express couldn't cope with it being defined again.
Removing this line from Web.config completely solved the problem.
It looks like your web site is configured to use SSL. Except that when running locally you probably do not have a valid SSL certificate which is trusted by a certification authority and the client browser is refusing to download the static resources. One way to fix that is to add the address as trusted. So copy paste the url to some of your CSS files in your browser address bar:
https://localhost/MyApp/Content/Main.css
and you will see a warning about the invalid certificate that you could ignore by adding an exception to your browser. Hit Ctrl+F5 to force a refresh once the exception is added and your application should start working properly.
When I had this problem I found that all of my CSS and Script files were encountering a HTTP 500 error when they were being downloaded in the browser (Firefox 33.0.2).
Killing the instance of my browser in the Task Manager and then starting afresh fixed the issue for me.

referring the image files from the Trdion server in Dreamweaver TBB in SDL Trdion 2011 Sp1

I am trying to refer the Images from the Web server of the Tridion.
<img src="file://///ServerAddress.com/applications/Images/Styles/temporary.jpeg" alt="alt text"/>
I have added this code my TBB.
The image is not getting displayed.
Added the same code in local html page in my machine, I am able to retrieve the that Image.
Edit:
Image is not getting displayed while previewing in Tridion CME.
Can any one suggest how to configure my image source path in TBB for accessing the Image.
Thanks in Advance.
You are using a file:// URL, which means that you are referring to a local file on the machine that opens the HTML. So when you open the HTML on the machine where you originally created it (and placed temporary.jpg), it will find the file locally and display it.
When you open the same HTML from any other machine, it will fail to find the file on that machine and thus won't display the image. The fact that you use ServerAddress.com makes no difference for that: file URLs will only resolve to file on the local machine.
If you want to ensure your images work properly for the rest of the internet too, use a more common protocol such as http://.

Problem with Default Document and IIS7.5/Windows 7

I'm having a problem with a component used in a Sitecore solution on our Windows 7 workstations that is driving me batty.
In short, the component in question adds <script> tags to the page that load supporting JavaScript files. The src attributes are set to something like:
/path/to/scriptgenerator/?r=1234&p=asdf
Those paths are not working - I'm getting a 404 back.
You might thing "oh ... well, the path doesn't exist." But it does, and it also has a Default.aspx page in it. In fact, if I try the following path, the JS is generated and returned by the server:
/path/to/scriptgenerator/Default.aspx?r=1234&p=asdf
We're testing the site using IIS7.5, not Visual Studio's debugging web server. Of course, on the production machines, which are Win Server 2008, things work just fine.
The component in question is a third-party component and I have no access to the source code, so I can't just modify it to append default.aspx to the SRC path.
I have checked to verify that Default.aspx is set up as a default document for the site, and it is.
I tried to work around the problem using ISAPI_Rewrite, but for some reason, rules that I set up for /path/to/scriptgenerator are ignored.
I've tried the solution described in these questions, and that has no effect on my problem:
IIS 7 Not Serving Default Document
ASP.NET 2.0 and 4.0 seem to treat the root url differently in Forms Authentication
I'm really not sure what to try or look for next ... any suggestions?
Is this component set up within the same IIS Site as the Sitecore application?
If so, have you added path /path/to/scriptgenerator to IgnoreUrlPrefixes setting in web.config?

Images are not showing up in application and even on the default iis website after new install of IIs7 on Vista x64

Seems like everything else works fine on my website but the images are not showing. No errors are being thrown either. Even the localhost default site image is not working. I have the static option turned on as well. Any ideas on how to fix this would be great.
You may have to turn Static Content on in World Wide Web Services / Common Http Features. This can be accessed via the 'Turn Windows Features on or off' section in the Control Panel.
See below for an example...
http://peterkellner.net/2008/04/01/iis7imageproblem/
When I get images not appearing it is because the files themselves don't have correct permissions. Go in and make sure that the files are inheriting permissions from their parent.

Resources