Ciao a tutti,
sono completamente niubbo di ASP.Net e quindi richiedo il vostro aiuto.
Ho un file di Login e uno di Logout in formato .aspx, che utilizzano il linguaggio Visual Basic per effettuare le operazioni (spero di essere chiaro....).
Quello che devo fare è creare un file di testo in cui vengano registrate le operazioni, file di testo che può già esistere (e quindi fare un controllo ed andare in append, o eventualmente crearlo).
Vi chiedo degli esempi da utilizzare, visto che non so praticamente nulla....

Questi sono i miei file:
Login.aspx
codice:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="login.aspx.vb" Inherits="login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<link href="css/dda.css" rel="stylesheet" type="text/css">
</head>
<body onload="document.form1.UserName.focus();" bgcolor="#ffffff" text="#000000" background="images/body.gif">
<form id="form1" runat="server">
<div align=center>
<table width="250" height="82" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#000066" bgcolor="#D8EEFE">
<tr>
<td height="80" valign="middle">
<div align="left">
<table width="250" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="88" class="formvari"><font size="2" face="Arial, Helvetica, sans-serif">Username:
</font></td>
<td width="162" class="formvari">
<asp:TextBox ID="UserName" runat="server" Font-Size="0.9em" CssClass="campiform"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ErrorMessage="*" ControlToValidate="UserName" CssClass="campiform"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="formvari"><font size="2" face="Arial, Helvetica, sans-serif">Password:
</font></td>
<td class="formvari">
<asp:TextBox ID="Password" runat="server" TextMode="Password" Font-Size="0.9em" CssClass="campiform"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ErrorMessage="*" ControlToValidate="Password" CssClass="campiform"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td></td>
<td class="formvari"> <input type="submit" name="Login1$LoginButton" value="Log In" class="tasti" onclick="<%Go() %>" />
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
<asp:TextBox ID="TextBox3" runat="server" Visible="false"></asp:TextBox>
<script language=javascript>
var sesval = '<%=Session("user_id") %>';
if(sesval>0) {
parent.frames(0).location.href = "headframe.aspx";
parent.frames(1).location.href = "/eu/menu.aspx";
parent.frames(2).location.href = "bblank.htm";
parent.frames(3).location.href = "bblank.htm";
parent.dettFr.rows = "0,*";
}
</script>
</form>
</body>
</html>
Login.aspx.vb
codice:
Imports DbUtils
Partial Class login
Inherits System.Web.UI.Page
Public Sub Go()
If UserName.Text <> "" And Password.Text <> "" Then
Dim cnt As Integer
Dim user_id, user_name, type_id, user_email, user_pwd, adm_mod As String
user_id = ""
user_name = ""
user_email = ""
type_id = ""
user_pwd = ""
adm_mod = ""
Dim strConn As String = Web.Configuration.WebConfigurationManager.ConnectionStrings("ConnString").ToString
Dim objConn As New SqlConnection(strConn)
Dim objCommand As New SqlCommand("SELECT user_id, type_id, user_firstname, user_surname, user_email,user_pwd,adm_mod, count(*) cnt FROM dda_users WHERE user_code = @user_code and user_pwd = @user_pwd group by user_id, type_id, user_firstname, user_surname, user_email, user_pwd, adm_mod", objConn)
objCommand.Parameters.Add("@user_code", SqlDbType.VarChar).Value = UserName.Text
objCommand.Parameters.Add("@user_pwd", SqlDbType.VarChar).Value = Password.Text
Dim da As New SqlDataAdapter(objCommand)
Dim dt As New DataTable()
da.Fill(dt)
For Each dr As DataRow In dt.Rows
cnt = dr("cnt")
user_id = dr("user_id").ToString
user_name = dr("user_firstname").ToString & " " & dr("user_surname").ToString
user_email = dr("user_email").ToString
type_id = dr("type_id").ToString
user_pwd = dr("user_pwd").ToString
adm_mod = dr("adm_mod").ToString
Next
If cnt > 0 Then
TextBox3.Text = "Accesso Ok"
Session("user_id") = user_id
Session("user_name") = user_name
Session("user_email") = user_email
Session("type_id") = type_id
Session("user_pwd") = user_pwd
Session("adm_mod") = adm_mod
Dim strwhere As String
If type_id <> "ADM" And type_id <> "SUP" Then
strwhere = "WHERE user_id = @user_id"
Else
strwhere = ""
End If
objCommand = New SqlCommand("SELECT site_id FROM v_user_sites " & strwhere & " group by site_id", objConn)
objCommand.Parameters.Add("@user_id", SqlDbType.Int).Value = CInt(user_id)
da = New SqlDataAdapter(objCommand)
dt = New DataTable()
da.Fill(dt)
Dim site_id As New String("")
For Each dr As DataRow In dt.Rows
If Not IsDBNull(dr("site_id")) Then
If site_id <> "" Then site_id = site_id & ","
site_id = site_id & dr("site_id").ToString
End If
Next
Session("site_id") = site_id
ElseIf cnt = 0 Then
TextBox3.Text = "User o password errati"
End If
dt.Dispose()
da.Dispose()
objConn.Dispose()
objCommand.Dispose()
End If
End Sub
End Class
Logout.aspx.
codice:
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%
Session("user_id") = 0
Session("type_id") = ""
Session.Abandon()
%>
<script language=javascript>
parent.frames(0).location.href = "headframe.aspx";
parent.frames(1).location.href = "bblank.htm";
parent.frames(2).location.href = "bblank.htm";
parent.frames(3).location.href = "login.aspx";
parent.dettFr.rows = "0,*";
</script>
</div>
</form>
</body>
</html>
Se per caso questo argomento è già stato trattato, linkatemi la pagina... non mi va la ricerca....