gpt4 book ai didi

asp.net - 请求在此上下文中不可用

转载 作者:行者123 更新时间:2023-12-02 14:09:39 25 4
gpt4 key购买 nike

Exception Details: System.Web.HttpException: Request is not available in this context

Source Error:

Line 7: Private Sub Application_Start(sender As Object, e As EventArgs)
Line 8: ' Caching the tracker image in memory
Line 9: Dim trackerImg As Byte() = File.ReadAllBytes(Context.Request.MapPath(ConfigurationManager.AppSettings("SD_Tut_ImageFileLocation")))
Line 10: Application(ConfigurationManager.AppSettings("SD_Tut_ImageFileKeyName")) = trackerImg

第 9 行有错误

这是 Global.asax 代码

<%@ Application Language="vb" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="Stardeveloper.Tutorial" %>

<script runat="server">
Private Sub Application_Start(sender As Object, e As EventArgs)
' Caching the tracker image in memory
Dim trackerImg As Byte() = File.ReadAllBytes(Context.Request.MapPath(ConfigurationManager.AppSettings("SD_Tut_ImageFileLocation")))
Application(ConfigurationManager.AppSettings("SD_Tut_ImageFileKeyName")) = trackerImg

' Creating a new request queue collection
Dim queueCapacity As Integer = Convert.ToInt32(ConfigurationManager.AppSettings("SD_Tut_TrackerRequestsToCache"))
Dim trackerReqQueue As New Queue(Of TrackerRequest)(queueCapacity)
Application(ConfigurationManager.AppSettings("SD_Tut_TrackerCachedRequestsKeyName")) = trackerReqQueue
End Sub

Private Sub Application_End(sender As Object, e As EventArgs)
' Storing the queued tracker reqs to database
Dim trackerReqQueue As Queue(Of TrackerRequest) = DirectCast(Application(ConfigurationManager.AppSettings("SD_Tut_TrackerCachedRequestsKeyName")), Queue(Of TrackerRequest))
Tracker.FlushRequestQueueCache(trackerReqQueue)
End Sub

</script>

最佳答案

我们正在处理什么版本的 IIS?如果是 7 或更高版本,则所做的更改可能会导致此行为。

参见this article.

关于asp.net - 请求在此上下文中不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6159747/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com