Asp.net 会话、httphandler和java小程序一起工作

Asp.net 会话、httphandler和java小程序一起工作,asp.net,applet,httphandler,Asp.net,Applet,Httphandler,我有一个aspx页面,请参见: <%@ Page Language="C#" %> <% HttpContext.Current.Session["UserID"] = "ABC1"; Response.Write(HttpContext.Current.Session["UserID"].ToString()); %> <script> var parameters = { OpenURL: "test.pdf", java_ar

我有一个aspx页面,请参见:

<%@ Page Language="C#" %>
<%

    HttpContext.Current.Session["UserID"] = "ABC1";
    Response.Write(HttpContext.Current.Session["UserID"].ToString());

%>
<script>
    var parameters = { OpenURL: "test.pdf", java_arguments: "-Xmx256m" };
  var attributes = {archive:"webviewerS.jar,jPDFViewerS.jar", code:"qoppa.webViewer.PDFWebViewer", width:"100%", Height:"95%"};
  var version = "1.6.0";

  deployJava.runApplet(attributes, parameters, version);
</script>
此脚本测试的主要目标是,仅通过在该aspx页面中使用javaapplet就可以查看pdf。但最后,

var参数={OpenURL:“test.pdf”,java_参数:“-Xmx256m”}

java小程序请求加载pdf,但在httphandler上似乎无法检测到会话,但如果在加载.aspx页面后直接键入.pdf路径,则上述代码是成功的


如果小程序请求pdf文件,seision[“UserID”]的结果将为空,为什么它无法检测会话值?

您是否尝试过使用类似的方法或看到小程序请求从浏览器返回到服务器

通常会有一个名为
ASP.NET_SessionId
的cookie,或者可能有一个名为
SessionId
的查询字符串参数来维护会话,具体取决于服务器配置

默认情况下,SessionID值存储在cookie中。但是,你可以 还要配置应用程序以在URL中存储SessionID值 参加一个“无厨师”的会议

Java小程序可能没有在请求中包含这个,因此服务器认为它是一个不同的会话

response.Cookies["UserID"].HttpOnly = false;
if (HttpContext.Current.Session["UserID"] != null)
{

        response.ContentType = "application/pdf";
        response.WriteFile(request.PhysicalPath);

}
else
{
    response.Write("access denied");
}