This snippet is in my Business Logic Layer Class File:
Public Shared Function getAccIDFromSocialAuthSession() As Object
Dim db As SqlDatabase = Connection.connection
Dim accID As Integer
If SocialAuthUser.IsLoggedIn Then
Using cmd As SqlCommand = db.GetSqlStringCommand("SELECT AccountID FROM UserAccounts WHERE [email protected]")
db.AddInParameter(cmd, "fbID", SqlDbType.VarChar, SocialAuthUser.GetCurrentUser.GetProfile.ID)
accID = db.ExecuteScalar(cmd)
End Using
End If
Return accID
End Function
I am using SocialAuth.Net. SocialAuth.NET
stores everything in session. For e.g to get the Facebook User ID we call SocialAuthUser.GetCurrentUser.GetProfile.ID
, since it is session based i get this error message "Object Reference Not Set to an instance of an object" when i try to call SocialAuthUser.GetCurrentUser.GetProfile.ID
from a webservice (asmx.vb) file. I am calling it like this (ClassName.FunctionName-->BLL.getAccIDFromSocialAuthSession)
Whaen i call the same function from a aspx.vb
page it works fine but not when i call it from an asmx.vb
page.
Since i do not know the session variable name , i cannot use System.Web.HttpContext.Current.Session("NameHere")
Any solution??
Here's the start of some working code:
Imports System.Web.Services
Imports System.ComponentModel
<System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class LightboxService
Inherits WebService
<WebMethod(EnableSession:=True)> _
Public Function AddToLightbox(ByVal filename As String) As String
Dim user As String = CStr(Session("username"))
'...etc.