Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.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
Asp.net 元素';system.web';具有无效的子元素';默认文档';_Asp.net_Web Config_Asp.net 4.0_Visual Studio 2012 - Fatal编程技术网

Asp.net 元素';system.web';具有无效的子元素';默认文档';

Asp.net 元素';system.web';具有无效的子元素';默认文档';,asp.net,web-config,asp.net-4.0,visual-studio-2012,Asp.net,Web Config,Asp.net 4.0,Visual Studio 2012,我正在训练我的web.config以识别最佳默认文件是什么。根据我的主人的说法,它应该看起来像下面的列表 <?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>

我正在训练我的web.config以识别最佳默认文件是什么。根据我的主人的说法,它应该看起来像下面的列表

<?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>
  <appSettings/>
  <system.web>

    <defaultDocument>
      <files>
        <clear />
        <add value="Defalut.aspx" />
      </files>
    </defaultDocument>

    <compilation debug="true" targetFramework="4.0"/>
    <httpRuntime/>
    <pages controlRenderingCompatibilityVersion="4.0"/>
    <machineKey/>
    <customErrors defaultRedirect="Error.aspx" mode="On"/>
  </system.web>
</configuration>

问题是VS2012(Express)将其标记为蓝色,并声称主题中存在错误。首先,我认为我可以上传它的原样,并通过暴力使服务器喜欢该文件,但后来它生气了,吐出以下内容

HTTP错误500.19-内部服务器错误 无法访问请求的页面,因为该页面的相关配置数据无效

当我阅读错误消息时,它说:“无法读取配置节‘defaultDocument’,因为它缺少节声明。”

我已经完成了我的家庭作业,找到了下面的文章,但由于我的情况限制(例如,我需要手动上传web.config文件,并且我无法在托管公司的服务器上运行任何脚本),这篇文章没有用

如何解决这个小问题?

“Defalut.aspx”是一个明确的黄色标志

建议:

  • 只需使用MSVS2012创建一个新的虚拟项目(我手头没有副本,所以目前无法帮助您)

  • 将自动生成的“web.config”剪切并粘贴到项目中,并验证它是否有效。 如果没有,则只进行那些最小的更改,以获得干净的编译/执行

  • 保存工作web.config的备份

  • 尝试添加“defaultDocument”部分,看看会发生什么

  • 如果仍然不起作用,请剪切/粘贴:

    a) 确切的部分(我猜你在上面做过)

    b) 确切的错误消息

  • 此外:

    Q:它现在在您的MSVS2012(本地运行)和目标web服务器上都失败了,对吗


    问:您确定目标web服务器支持ASP.Net 4.0吗?

    您的配置看起来正确,但出现错误是因为它找不到作为所有网站文件夹默认文档的文件

    因此,请用下面xml中文件的正确拼写替换“Defalut.aspx”

    <defaultDocument>
          <files>
            <clear />
            <add value=*"Defalut.aspx"* />
          </files>
        </defaultDocument>
    

    我知道聚会迟到了,但对于仍然有类似问题的人来说,我认为这与默认页面名称的拼写无关(访问时可能只会给出404)

    真正的问题是
    defaultDocument
    部分实际上应该在
    system.webServer
    下,而不是
    system.web
    下。有关更多信息,请参阅

    因此,您的示例配置文件应该如下所示:

    
    
    这肯定是一个问题区域,但我不认为这是问题的原因,因为错误消息抱怨标签未被识别,而不是文件未被找到。事实上,VS非常清楚地指出“未识别的配置部分system.web/defaultDocument”另外,我已经纠正了拼写错误,错误依然存在。祝你拼写错误检测顺利。好眼睛!我按照您的要求做了(不需要做任何更改),并使其与“新鲜”版本的web.config一起工作。然后我添加了defaultDocument标记,并获得了将粘贴到下一条注释中的消息。元素“system.web”的子元素“defaultDocument”无效。可能需要的元素列表:'anonymousIdentification、authentication、authorization、browserCaps、clientTarget、编译、customErrors、deployment、DeviceFilter、FullTrustAssembly、全球化、healthMonitoring、hostingEnvironment、httpCookies、HttpHandler、HttpModule、httpRuntime、identity、machineKey、membership、mobileControls、,页面、PartialTrustVisibleSassembles、processModel、profile、roleManager、securityPolicy、sessionPageState、sessionState、siteMap、跟踪、信任、urlMappings、WebControl、webParts、webServices、xhtmlConformance、caching'.C:\…\Web.configIt还列出了我在下面的评论中提到的错误消息。上面写着:“无法识别的配置节system.web/defaultDocument.C:\…\web.config”(省略号是为了便于阅读)