复制IIS网站后,web.config设置的默认页面未被IIS识别
问题:复制IIS站点后默认页面失效,仅显示目录列表
复制现有IIS网站文件夹至新目录并搭建新站点后,web.config中设置的默认页面未被IIS识别。输入站点URL时仅显示目录列表(可关闭目录列表选项隐藏),且未修改过该站点的默认页面设置。
现有web.config相关配置
<authentication mode="Forms"> <forms loginUrl="~/account/signin" timeout="600" cookieless="UseCookies" /> </authentication>
更新内容:applicationHost.config相关片段
<applicationPools> <add name="student2" autoStart="true" enable32BitAppOnWin64="true" managedRuntimeVersion="v4.0" /> <applicationPoolDefaults managedRuntimeVersion="v4.0"> <processModel identityType="ApplicationPoolIdentity" /> </applicationPoolDefaults> </applicationPools> <site name="student2" id="20" serverAutoStart="true"> <application path="/" applicationPool="student2"> <virtualDirectory path="/" physicalPath="C:\Websites\student2" /> </application> <bindings> <binding protocol="http" bindingInformation="*:52000:" /> </bindings> </site>
解决步骤
确认站点默认文档配置
打开IIS管理器,找到student2站点,双击「默认文档」,检查所需默认页面(如default.aspx、index.aspx或对应登录页)是否在列表中且顺序靠前。若缺失,点击「添加」输入文件名并调整顺序。在web.config中添加默认文档配置
当前web.config仅包含Forms认证设置,需补充默认文档配置(若不存在system.webServer节点则新建):<system.webServer> <defaultDocument enabled="true"> <files> <add value="default.aspx" /> <!-- 替换为你的实际默认页面文件名 --> </files> </defaultDocument> <!-- 可选:关闭目录列表 --> <directoryBrowse enabled="false" /> </system.webServer>验证应用程序池设置
在IIS管理器的「应用程序池」中找到student2,右键选择「高级设置」,确认「托管管道模式」为Integrated(ASP.NET项目推荐),确保与站点框架版本匹配。检查文件夹权限
右键C:\Websites\student2文件夹→「属性」→「安全」,添加IIS AppPool\student2用户,分配「读取」和「列出文件夹内容」权限,确保应用池能访问站点文件。重启站点与应用池
在IIS管理器中右键student2站点选择「重启」,同时重启student2应用池,使配置生效。
内容的提问来源于stack exchange,提问作者sm101
相关产品推荐
相关产品推荐

