views:

85

answers:

3

What am I missing here??? For some reason, anytime I reference a .png from my application.css file I get prompted for credentials. BUT, I can reference .gifs, .jpegs, etc... from my images directory no problem.

Routes are set up right now like this ...

public static void RegisterRoutesTo(RouteCollection routes) {

        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.IgnoreRoute("elmah.axd");
        routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });

        routes.MapRoute(
            "Default", "",                   
            new { controller = "Home", action = "Index"}  // Parameter defaults
        );

        routes.MapRoute(
            "Session", "{action}",
            new { controller = "Session" },
            new { action = "(login|logout|register)" }
        );



        routes.MapRoute("CatchAll",  "{*catchall}",
            new { controller = "Error", action = "NotFound" });
    }

In my application.css I have this:

.iconLocationLarge { background-image: url(../images/icon_vcarea_48x48.png) !important;}
.iconVCLarge { background-image: url(../images/tb-btn-sprite.gif) !important;}

The Problem: I get prompted to authenticate again if I use a .png ... BUT not with the .gif. Why???

A: 

I am not sure why, but probably you should add ignore routes for all static content regardless.

http://stackoverflow.com/questions/2730335/asp-net-mvc-thinks-my-virtual-directory-is-a-controller/2730472#2730472

Mahesh Velaga
This did not work. ASP.NET still attempting to process .png files rather than serving them up like any other image (e.g. .gif, .jpeg)
wgpubs
+2  A: 

IIS can serve content directly without passing the request to ASP.NET. I suspect in your case that IIS is set to serve GIF and JPG but not PNG. See for example http://mvolo.com/blogs/serverside/archive/2006/11/10/Stopping-hot_2D00_linking-with-IIS-and-ASP.NET.aspx for a discussion on the topic. See also http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/4c840252-fab7-427e-a197-7facb6649106.mspx?mfr=true.

Assuming this is IIS6, open the IIS Manager from Administrative Tools, right click on the local computer node, click on MIME types, check that PNG is registered as "image/png". You can also configure this at the individual web site level.

Make sure there is no other filter that could cause the issue, e.g. the UrlScan ISAPI filter.

Hightechrider
This appears to be the case. Question is ... what do I need to include in setup so that PNG is process like GIF and JPG? As far as I can tell, there is nothing specific for gifs/jpegs and so I'd assume that png would be processed the same way.
wgpubs
You need to check your IIS configuration, see updated answer.
Hightechrider
Yes ... PNG is registered and mapped to image/png. And I don't see any filters per se that would cause the issue.
wgpubs
See the solution below. This was happening because the PNG files I was hitting had the encryption bit set. Thanks for your comments though as I'm sure they will be of value to someone perusing this thread at some point.
wgpubs
A: 

Finally solved:

The PNG files I was referencing were encrypted. That is it.

After finally exhausting all other options with IIS and ASP.NET I noticed that each PNG file I was referencing had the attributes "AE" (E= Encrypted). So the solution was to right-click the folder, click "Advanced" button and de-select the "Encryption" option.

wgpubs