做了一个基于session的身份验证(只是验证,登录放在.aspx中),希望把它放进Userchk.asmx,作用是根据session["username"]取得用户的详细信息.调试Userchk.asmx,可以成功得到用户详细信息。但实际调用Userchk.asmx(用代理类)时却无法得到用户详细信息。
各位帮忙~~~

解决方案 »

  1.   

    我调用时已经使用了CookieContainer,不行
      

  2.   

    你可以把验证Session放在外头.aspx
    然后根据传进Web Services值,让他在.asmx里处理呗
      

  3.   

    在一个应用程序(项目)中应该没问题了session不能跨应用程序,你的代理是不是在其它的应用程序中呢?
      

  4.   

    不好意思,我把部分代码贴出来//.asmx
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Web;
    using System.Web.Services;
    using class1.blica;
    namespace class1.alica
    {
    /// <summary>
    /// Service1 的摘要说明。
    /// </summary>
    public class UserCHK : System.Web.Services.WebService
    {
    public UserCHK()
    {
    //CODEGEN: 该调用是 ASP.NET Web 服务设计器所必需的
    InitializeComponent();
    }
    [WebMethod(true)]
    public string[] PassPort()
    {  
     string[] arry1= new string[4];
        Baseuser Baseuser1 = new Baseuser();
    this.user = BasePage1.NewUser("dfdf");
    arry1[0] =this.user.userName.ToString();
    arry1[1] =this.user.UserID.ToString();
    arry1[2] =this.user.GroupID.ToString();
    arry1[3] =this.user.Realname.ToString();

    return arry1; }
    public userInfo user;
    }
    }
    //调用Public Class Form1
        Inherits System.Windows.Forms.Form
        Public Cookies As System.Net.CookieContainer
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
          Try                Dim ca As chk.UserCHK = New chk.UserCHK
                    chake.CookieContainer = CookieCnt
                    Me.Label2.Text = (ca.PassPort()(0)).ToString()
                    Me.Label3.Text = (ca.PassPort()(1)).ToString()
                    Me.Label4.Text = (ca.PassPort()(2)).ToString()
                    Me.Label5.Text = (ca.PassPort()(3)).ToString()
                Catch ex As Exception
                    Response.Write(ex.ToString())
                End TryEnd Class
      

  5.   

    winform和aspx调用都失败了,顶~`