请求在此上下文中不可用
请求在此上下文中不可用
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Web.HttpException: 请求在此上下文中不可用
源错误:
行 9:
行 10: 'Dim e_companyid As String = Request.Cookies("e_companyid").Value
行 11: Dim e_companyid As String = Request.Cookies("dm").Value
行 12:
行 13: Protected Sub content1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles content1.Load
源文件: E:\nengyuan\aa\tb4.aspx.vb 行: 11
堆栈跟踪:
[HttpException (0x80004005): 请求在此上下文中不可用]
System.Web.UI.Page.get_Request() +2077605
tb4..ctor() in E:\nengyuan\aa\tb4.aspx.vb:11
ASP.tb4_aspx..ctor() in E:\nengyuan\aa\tb4.aspx.vb:912304
__ASP.FastObjectFactory_app_web_igzmi_6v.Create_ASP_tb4_aspx() +38
System.Web.Compilation.BuildResultCompiledType.CreateInstance() +49
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +115
System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +31
System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +40
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +139
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +128
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +161
[解决办法]
你读取的方法不对啊 应该是Request.Cookies["e_companyid"].Value
cookie有可能是空的 或者不存在的
判断一下 最好
if(Request.Cookies["e_companyid"] != null)
string e_companyid = Request.Cookies["e_companyid"].Value;