G
Guest
Hi groups,
Can anyone give me the equivalent C# sharp code for this VB.ET code,
:: VB.NET ::
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) _
Handles MyBase.Load
'This event routine in the loginCheck user control fires when the
protected
'page loads. If the user hasn't logged in, loginCheck redirects the
user to
'the page specified by LoginPageURL for validation. If the user has
logged in,
'he or she gets access to the protected page.
If Not Enabled Then Exit Sub
If IsNothing(Session("LoginType")) Then Exit Sub
If CType(Session("LoginType"), _
String).Length > 0 Then
If IsNothing(Session(LoginPageURL & _
"_Valid")) Then
Session("LoginTarget") = _
Request.ServerVariables _
("Script_Name")
Response.Redirect(LoginPageURL)
Else
If CType(Session(LoginPageURL & _
"_Valid"), String).Length = 0 Then
Session("LoginTarget") = _
Request.ServerVariables _
("Script_Name")
Response.Redirect(LoginPageURL)
End If
End If
End If
End Sub
C#?
I used an auto tool to do this and got:
The MS VS 2003 always complains "Session" as below:
c:\inetpub\wwwroot\passwordProtectCSharp\Global.asax.cs(42):
'System.Web.HttpApplication.Session' denotes a 'property' where a 'method'
was expected
Anyone has any suggestions?
Thanks. -Dale
Can anyone give me the equivalent C# sharp code for this VB.ET code,
:: VB.NET ::
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) _
Handles MyBase.Load
'This event routine in the loginCheck user control fires when the
protected
'page loads. If the user hasn't logged in, loginCheck redirects the
user to
'the page specified by LoginPageURL for validation. If the user has
logged in,
'he or she gets access to the protected page.
If Not Enabled Then Exit Sub
If IsNothing(Session("LoginType")) Then Exit Sub
If CType(Session("LoginType"), _
String).Length > 0 Then
If IsNothing(Session(LoginPageURL & _
"_Valid")) Then
Session("LoginTarget") = _
Request.ServerVariables _
("Script_Name")
Response.Redirect(LoginPageURL)
Else
If CType(Session(LoginPageURL & _
"_Valid"), String).Length = 0 Then
Session("LoginTarget") = _
Request.ServerVariables _
("Script_Name")
Response.Redirect(LoginPageURL)
End If
End If
End If
End Sub
C#?
I used an auto tool to do this and got:
The MS VS 2003 always complains "Session" as below:
c:\inetpub\wwwroot\passwordProtectCSharp\Global.asax.cs(42):
'System.Web.HttpApplication.Session' denotes a 'property' where a 'method'
was expected
Anyone has any suggestions?
Thanks. -Dale