HI currently I am studying asp.net, how ever I manage to view my image just in my test.aspx page using this code

<img src="img/image.jpg" >

but when i use it on my login.aspx using the same code no image shows up.

can anyone help me about this?

Dani AI

Generated

Short answer: when ASP.NET Forms Authentication protects your site it can also block static files (images) unless those files or their folder are explicitly allowed to anonymous users. hit this exact case.

If an image request is being intercepted by Forms Authentication the browser will get a redirect to the login page (or a 401) instead of the image. Quick checks: open the browser DevTools Network tab, reload the page, and look at the image request — if you see a 302/redirect to your login page or an HTML response where an image should be, the auth module is the culprit.

Common, practical fixes:

  • Allow anonymous access to the images folder by adding a <location> entry in web.config that grants access to everyone. For example:
<configuration>
  <location path="img">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>
</configuration>
  • Or move static assets to a public folder (or serve them from a CDN).
  • If using IIS7+ integrated pipeline and you set runAllManagedModulesForAllRequests="true", be aware managed modules will see static requests; either allow the folder as above or change that setting carefully.

Security note: only allow anonymous access for truly public assets. Also confirm the image path is correct (use root-relative paths to avoid folder-relative mistakes) and verify the file exists and is reachable after changing config.

ok I manage to Solve the problem. the problem was I am using a Form authentication and included my images.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.