我最近遇到了一个错误,试图用IIS托管我的asp.net站点。我找到了一个很多人信誓旦旦的解决办法。

解决方案: 对文件夹中的文件添加具有读权限的IIS_IUSRS 修改IIS认证方式为BasicAuthentication 刷新网站。会有用的

(http://vivekthangaswamy.blogspot.com/2009/07/aspnet-website-cannot-read.html)

我在我的网里加了什么?配置文件?我以前从来没编辑过。以下是其当前内容:

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
    <connectionStrings>
  <add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
   providerName="System.Data.SqlClient" />
 </connectionStrings>
 <system.web>
  <compilation debug="true" strict="false" explicit="true" targetFramework="4.0"/>
    </system.web>
</configuration>

我的错误是:

配置错误:由于权限不足,无法读取配置文件 配置文件:\?\ C: \用户* * * * *网站视觉Studio2010 \ \文件\ \ PointsForTime \ web . config


当前回答

我尝试了以前的大部分建议,但都没有用。我无法重新加载网站,所以我编辑了.csproj文件并更改了端口号,它立即工作了:

 <WebProjectProperties>
      <UseIIS>True</UseIIS>
      <AutoAssignPort>True</AutoAssignPort>
      <DevelopmentServerPort>**4000**</DevelopmentServerPort>
      <DevelopmentServerVPath>/</DevelopmentServerVPath>
      <IISUrl>http://localhost:**4000**/</IISUrl>
      <NTLMAuthentication>False</NTLMAuthentication>
      <UseCustomServer>False</UseCustomServer>
      <CustomServerUrl>
      </CustomServerUrl>
      <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
    </WebProjectProperties>

编辑.csproj文件

其他回答

转到父文件夹,右键单击并选择属性。选择“安全”选项卡,编辑权限并添加。单击“高级”和“立即查找”。选择“IIS_IUSRS”,单击“确定”,然后再次单击“确定”。确保你有检查写。单击“确定”,再单击“确定”。

完成工作!

所有给出的答案都是有效的,并在不同的情况下工作。

对我来说,重新启动Visual Studio起作用了。

出于某种原因,你的网。Config设置为只读。取消选中web的只读选项。配置文件。

当IIS应用程序有一个物理路径包含正斜杠/而不是反斜杠\的虚拟目录时,我们就遇到了这种情况。这是在我们的持续交付过程中使用IIS的powershell管理API意外完成的。

错误配置示例- applicationHost.config . Config

<application path="/MySite/MyService" applicationPool="MyAppPool" enabledProtocols="http">
    <virtualDirectory path="/" physicalPath="C:\inetpub\MySite/MyService" />
</application>

确保physicalPath属性不包含正斜杠/,只包含反斜杠\

- applicationHost.config . Config

<application path="/MySite/MyService" applicationPool="MyAppPool" enabledProtocols="http">
    <virtualDirectory path="/" physicalPath="C:\inetpub\MySite\MyService" />
</application>

如果应用程序位于虚拟目录中,而文件的路径是映射驱动器,就会发生这种情况。

如果您将文件的路径更改到本地驱动器,这将解决问题,如果这确实是您的问题。