如何在angular2中获取会话数据

时间:2017-01-30 04:33:07

标签: c# asp.net session angular

尝试了

 getLogin():Observable<Login>
  {
    this.headers = new Headers();
    this.headers.append('Content-Type', 'application/json; charset=utf-8');                
    let options = new RequestOptions({
    method: RequestMethod.Post,
   url: "Attend.aspx/getLogin",                   
   headers: this.headers,
   body:{}
   });
            return this._http.request(new Request(options)).retry(2)
            .map((response: Response) => JSON.parse(response.text()))
            .do(data => console.log('getFacultyList: ' + data))
             .catch(this.handleError);              
   }

尝试了以下方式,但其静态方法使我无法访问会话数据

  [System.Web.Services.WebMethod]
  public static string getLogin()
  { 
    return "session data ";
  }

我在旧项目中使用以下方式在JavaScript中获取C#会话数据。

     <script type="text/javascript"> 
      var programme = "<%= Session["tmtbl_programname"]%>";
      var locate   = "<%= Session["tmtbl_location"] %>";
     </script>

问题

1)如何使用session data in angular2

2)如何get Session data which are assign in C# code which use in angular2

0 个答案:

没有答案