403 Forbidden error in Public Folder when I try re

2019-06-11 09:11发布

问题:

I have ASP.NET site.

I can access to the public page, it's OK:

http://mysite/MyPublicFolder/index.htm

But I get 403 error when I try access to the folder:

http://mysite/MyPublicFolder/

MyPublicFolder contains index.htm.

I want Not allow users to browse directory, only Access to all pages in Folder.

We have the following error:

403 - Forbidden: Access is denied

You do not have permission to view this directory or page using the credentials that you supplied.

<location path="/MyPublicFolder">
  <system.web>
     <authorization>
        <allow users="*"/>
     </authorization>
  </system.web>
 </location>

I am using IIS 7.5, Windows Server 2008 R2.

Any suggestions?

UPDATE: web.config

Note: v1 is my Public Folder

<location path="v1">
    <system.web>
      <authorization configSource="Config\system.web.authorization.allow.config" />
    </system.web>

    <system.webServer>
      <defaultDocument>
        <files>
          <add value="index.htm"/>
        </files>
      </defaultDocument>
      <httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
          <add wildcard="*" destination="/v1/index.htm" />
        </httpRedirect>
    </system.webServer>

  </location>

    <location path="v1/index.htm">
    <system.webServer>
      <httpRedirect enabled="false" />
    </system.webServer>
  </location>

回答1:

First thing that is in my mind is default document. Do you have it set to 'index.htm'? Here is a bit more info.



回答2:

It sounds a bit confusing. You are saying that you can open http://mysite/MyPublicFolder/index.htm what means that you have already got an access to all the pages located in this folder. I can just guess that you expect to get a redirect to index.htm file when you access a folder. Check out Default Document section in the IIS manager and make sure that index.htm is there.

UPDATE:

Looks like there are a lot of useless configuration in your web.config file. Change it to the following:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="v1">
    <system.web>
      <authorization configSource="Config\system.web.authorization.allow.config" />
    </system.web>
  </location>
</configuration>

Now if you access your v1 folder it should automatically show you content of your index.htm file.