我在运行IIS8的Windows Server 2012上托管我的网站。代码是用VB.NET编写的。
截至昨天,我的网页会在点击链接按钮后在新标签页中打开PDF以查看(不下载)。仅当数据库中存在关联文件时,链接按钮才有效。
If (myreader(49) = "" And myreader(52).ToString() = "0") Then
lnkAttachment.Text = "N/A"
lnkAttachment.Enabled = False
Else
lnkAttachment.Text = "Click Here"
lnkAttachment.Enabled = True
单击按钮后,它将在新选项卡中打开PDF。它停止工作,现在显示一个通用的运行时错误。
生成此页面链接的代码是:
Protected Sub lnkAttachment_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkAttachment.Click
Dim wdwOpen As String = "window.open('" & "../Attachment/" & Session("ID") & ".pdf" & "','_blank');"
Response.Write("<script>")
Response.Write(wdwOpen)
Response.Write("</script>")
End Sub
我有web.config文件和IIS错误页面设置应该显示详细的错误信息:
<system.web>
<customErrors mode="Off"/>
</system.web>
我在此IIS站点下安装了多个应用程序。有问题的人(WO)是唯一一个我无法打开PDF的人。我在这个网站下有另一个申请,显示PDF文件没有问题。我想说这是一个IIS问题,但我无法确定错误是什么。
我已进入C:\ inetpub \ logs \ LogFiles \ W3SVC1文件并找到以下行:
2016-07-20 13:29:22 (server ip address) GET /WO/Attachment/40147.pdf - 443 - 192.168.0.2 Mozilla/5.0+(iPhone;+CPU+iPhone+OS+9_3_2+like+Mac+OS+X)+AppleWebKit/601.1.46+(KHTML,+like+Gecko)+Version/9.0+Mobile/13F69+Safari/601.1 - 500 0 0 31
它显示500错误,但对于我的生活,我无法解决这个问题。我通过网络搜索找到了大量的信息,但我找不到具体的问题。代码如何工作一天然后停止下一个,并且只针对IIS中的一个站点下的一个应用程序。
关于可能出现什么问题的任何想法?
编辑: 每个illinoistim的事件查看器摘录评论:
Event code: 3008
Event message: A configuration error has occurred.
Event time: 7/21/2016 6:55:26 AM
Event time (UTC): 7/21/2016 11:55:26 AM
Event ID: 949451611c784e7695ead3f75ea8d6b5
Event sequence: 125
Event occurrence: 3
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1/ROOT/WO-15-131135755702094878
Trust level: Full
Application Virtual Path: /WO
Application Path: C:\inetpub\wwwroot\OHAS\WODB\
Machine name: (Machine Name)
Process information:
Process ID: 22580
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE
Exception information:
Exception type: ConfigurationErrorsException
Exception message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. (C:\inetpub\wwwroot\OHAS\WODB\attachment\web.config line 86)
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Web.Configuration.RuntimeConfig.GetSectionObject(String sectionName)
at System.Web.Configuration.RuntimeConfig.GetSection(String sectionName, Type type, ResultsIndex index)
at System.Web.Configuration.RuntimeConfig.get_Identity()
at System.Web.HttpContext.SetImpersonationEnabled()
at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
Request information:
Request URL: (site URL)
Request path: /WO/attachment/40147.pdf
User host address: 192.168.20.1
User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITY\NETWORK SERVICE
Thread information:
Thread ID: 57
Thread account name: NT AUTHORITY\NETWORK SERVICE
Is impersonating: False
Stack trace: at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Web.Configuration.RuntimeConfig.GetSectionObject(String sectionName)
at System.Web.Configuration.RuntimeConfig.GetSection(String sectionName, Type type, ResultsIndex index)
at System.Web.Configuration.RuntimeConfig.get_Identity()
at System.Web.HttpContext.SetImpersonationEnabled()
at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
Custom event details:
答案 0 :(得分:1)
所以这是交易。感谢illinoistim关于访问事件查看器的评论,我能够使用内容进行搜索。
显然我无意中将web.config文件从根文件夹复制到附件子文件夹中。我打算对我的web.config文件进行更改,所以我将它复制到桌面上的临时文件夹中以防万一。我怀疑,因为我有一个可编程鼠标,并且文件仍然存储在剪贴板中,我必须选择了附件文件夹并点击我的&#34;粘贴&#34;鼠标上的按钮。两个.config文件都有标记。此标记仅在应用程序级别允许。