Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Path 位置路径设置在IIS 7.5上不起作用,导致图像无法显示在登录页面上_Path_Location - Fatal编程技术网

Path 位置路径设置在IIS 7.5上不起作用,导致图像无法显示在登录页面上

Path 位置路径设置在IIS 7.5上不起作用,导致图像无法显示在登录页面上,path,location,Path,Location,我们有一个web应用程序,除非用户登录,否则不会显示图像和css。 我们正在使用表单身份验证 <authentication mode="Forms"> <forms loginUrl="~/Account/LogOn" timeout="2880" cookieless="UseCookies" /> </authentication> 现在,我们已经在web.config文件中专门使用了这个underconfiguration

我们有一个web应用程序,除非用户登录,否则不会显示图像和css。 我们正在使用表单身份验证

    <authentication mode="Forms">
    <forms loginUrl="~/Account/LogOn" timeout="2880" cookieless="UseCookies" />
    </authentication>

现在,我们已经在web.config文件中专门使用了这个underconfiguration部分,以允许匿名用户访问“content”文件夹

    <location path="Content">
    <system.web>
    <authorization>
    <allow users="?"/>
    </authorization>
    </system.web>
    </location>      

但仍然没有图像,没有css显示,除非登录。若我们试图直接访问一个图像,它会带我们进入登录页面。
有人知道发生了什么吗?

如果您试图在IIS 7.5中显示图像,您是否注意到有两种方法可以使用
标记,这甚至让我感到困惑

无论如何,如果您使用的是IIS 7.5,这可能会有所帮助

下面的示例适用于一个以Net4.5为目标的MVC应用程序,它将为一个组显示一个文件夹,并为另一个组隐藏该文件夹

<configuration>
  <system.web>
    <!-- allow only windows users to use app (no anonymous will access it)-->
    <authentication mode="Windows" />
    <authorization>
      <deny users="?" />
    </authorization>
  <system.web>

  <!-- main security, allowing only groups: Clowns and Nerds -->
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
        <security>
            <authorization>
                <remove users="*" roles="" verbs="" />
                <add accessType="Allow" roles="Domain\Clowns" />
                <add accessType="Allow" roles="Domain\Nerds" />
            </authorization>
        </security>
        <defaultDocument enabled="false" />
  </system.webServer>

  <!-- Here we show /images_for_clowns folder ONLY to Clowns group -->
  <location path="images_for_clowns" inheritInChildApplications="false">
     <system.webServer>
       <validation validateIntegratedModeConfiguration="false" />
        <security>
            <authorization>
                <clear />
                <remove users="*" roles="" verbs="" />
                <add accessType="Allow" roles="Domain\Clowns" />
            </authorization>
        </security>
        <defaultDocument enabled="false" />
     </system.webServer>
  </location>

  <!-- Here we show /images_for_nerds folder ONLY to Nerds group -->
  <location path="images_for_nerds" inheritInChildApplications="false">
     <system.webServer>
       <validation validateIntegratedModeConfiguration="false" />
        <security>
            <authorization>
                <clear />
                <remove users="*" roles="" verbs="" />
                <add accessType="Allow" roles="Domain\Nerds" />
            </authorization>
        </security>
        <defaultDocument enabled="false" />
     </system.webServer>
  </location>

也许另一个窍门是使用

<location path=".">
     <system.webServer>...

...
以设置根文件夹权限!希望这能帮助更多的人