ASP.NET MVC asks me to re-authenticate PNG files, but not GIF or JPEG

For some reason, when I reference the PNG from my application.css file, I get a credential request. However, I can link to GIF, JPEG, etc. From the catalog of images without problems.

My routes are configured as follows:

 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 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 is that I get a re-authentication request if I use PNG but not with GIF. Why?

+4
source share
3 answers

Finally solved:

The PNG files I referred to were encrypted. That's all.

After exhausting all the other parameters using IIS and ASP.NET, I noticed that every PNG file I referenced had the attributes "AE" (E = Encrypted). Thus, the solution was to right-click the folder, click the Advanced button, and deselect Encryption.

+2
source

IIS can directly serve content without sending an ASP.NET request. In your case, I suspect that IIS is configured 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 of 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 "Administration", right-click on the local node computer, select the MIME types, verify that PNG is registered as "image / png". You can also configure this at the individual website level.

Make sure there is no other filter that could cause the problem, for example. ISPI UrlScan filter.

+2
source

I'm not sure why, but you should probably add ignore routes for any static content independently.

ASP.NET MVC thinks my virtual directory is a controller

0
source

All Articles