Asp.net Images are giving 401 unauthorized error randomly
Asked Answered
D

5

8

I am using Asp.net, IIS 6 and cdn for serving images. I am having a problem with loading the images in my website. images are under a virtual folder. Everytime I hit refresh of the browser, some of the images gives 401 unauthorized error. (images and number of images displayed which gives 401 error differs in every refresh.) I am having hard time to solve this problem. Any help will be welcomed a lot.

Kind Regards.

PS: I am also using a load balancer to distribute traffic among two servers. One of the servers has actual files and a virtual folder for them. The other server has virtual folder which shows the path and ip of the server which has files. I tried using website via each server but they both have the same problem.

Here are the headers;

Response:

HTTP/1.1 401 Unauthorized
Content-Length: 1608
Content-Type: text/html
Server: Microsoft-IIS/6.0
Date: Thu, 28 Apr 2011 14:38:55 GMT

Request

GET /img/blog/2011%2f4%2f4.png HTTP/1.1
Host: cdn.***.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16 ( .NET CLR 3.5.30729)
Accept: image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://www.***.com/Blog
Dyslexia answered 28/4, 2011 at 14:16 Comment(6)
I don't know the actual answer to this, but perhaps you should set up a single share between the two and use virtuals for both, maybe that would at least help isolate the problem.Haphtarah
Thank you for your interest but it is already like that, I edited the question accordingly.Dyslexia
Actually I am not really sure if there is a problem with caching or virtual folder permissions. I am open to any suggestions.Dyslexia
Have you tried little hackalicious fixes, like setting all permissions to everyone at the top and let it recurse down through your directory?Haphtarah
Is your virtual directory referencing a network UNC path? If so you need to ensure you specify credentials that have access to that path, or ensure your application pool identity has access to that path.Bundesrat
On each server, try adding a custom Http Header (something that only you will understand) so you can know which server is generating the error. you can do it in IIS Manager or in the <customHeaders> section. (IIS Docs)Rollmop
D
15

Add permission for following users to that virtual image folder

  1. IUSR
  2. IIS_IUSRS

After adding the above permission please check whether 401 error is still there or not?

Daukas answered 20/9, 2012 at 11:35 Comment(0)
L
0

please set the security permission of your site images folder to iis_user or everyone and give its full rights and this error resolved forever.

Try this in my one site i got same problem and by using this way i resolved this error....

Lustig answered 9/6, 2011 at 14:28 Comment(0)
E
0

If the problem images change with each refresh, it's probably not a permissions issue - sounds instead like there is some kind of locking going on. Do you have the indexing service turned on, or an AV solution running?

Emeraldemerge answered 6/9, 2011 at 0:1 Comment(0)
E
0

Have you investigate IIS logs? This is, almost 100% sure, related with the access level the virtual folder and you may need to set special credentials when opening the target location.

How to enable IIS 6 logging? Here. How to analyze IIS logs? Here.

Epigone answered 15/11, 2011 at 9:51 Comment(0)
A
0

Make sure the mime-types are for the extensions you use of images are configures in your IIS.

Alto answered 6/3, 2012 at 10:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.