Hello,
i want if a user is connected in my web application some informations (IdUser,name date .. ) are insert in my table History in database sql server.
my class table:History.cs
- namespace GEC.DATA
- {
- using System;
- using System.Collections.Generic;
- public partial class History
- {
- public int HistoryID { get; set; }
- public string Description { get; set; }
- public string IpAddress { get; set; }
- public Nullable
DateEvenement { get; set; } - public Nullable<int> CodeUser { get; set; }
- public string Resultat { get; set; }
- public Nullable
HeureEvenement { get; set; } - }
- }
my controller:
- public class LoginController : Controller
- {
- [HttpPost]
- public ActionResult Login(LoginViewModel loginViewModel, string returnUrl)
- {
- var Authentifie = HttpContext.User.Identity.IsAuthenticated;
- ViewData["Authentifie"] = Authentifie;
- if (ModelState.IsValid)
- {
- User user = usersDAL.VerifyCredential(loginViewModel.LogedUser.Login, loginViewModel.LogedUser.Password);
- if (user != null)
- {
- FormsAuthentication.SetAuthCookie(user.UserID.ToString(), false);
- if (!string.IsNullOrWhiteSpace(returnUrl) && Url.IsLocalUrl(returnUrl))
- return Redirect(returnUrl);
- return Redirect("/");
- }
- ModelState.AddModelError("User.Login", "Login et/ou mot de passe incorrect(s)");
- }
- return View(loginViewModel);
- }
- }
my view Login.cshtml:
- class="login-body">class="login-title">Bonjour, Connectez vous
- @using (Html.BeginForm(null, null, new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { id = "loginform" }))
- {
class="form-horizontal">class="form-group">class="col-md-12">- @Html.EditorFor(model => model.LogedUser.Login, new { htmlAttributes = new { @class = "validate[required] form-control", placeholder = "Username" } })
- @Html.ValidationMessageFor(model => model.LogedUser.Login, "", new { @class = "text-danger" })
- @*"text" class="form-control" placeholder="Username" />*@
class="form-group">class="col-md-12">- @Html.PasswordFor(model => model.LogedUser.Password, new { @class = "validate[required] form-control", placeholder = "Password" })
- @Html.ValidationMessageFor(model => model.LogedUser.Password, "", new { @class = "text-danger" })
- @*"text" class="form-control" placeholder="Password" />*@
class="profile-data-title" id="UserId">class="form-group">class="col-md-6">- ="btn btn-info btn-block" id="LoginId" onclick="clicked();">Log In
- Html.EndForm();
- }
with this example authentification in my web app works goog , but what i want if i press button id="LoginId"
with event onclick I execute my javascript function clicked(); wich allows me to insert in my database
i want only how i can get information of authentificaion in my function javascript
thanks
Sachin SinghPosted Mar 9, 2021, 11:33 AM
Mouhssine tahriPosted Mar 9, 2021, 12:51 PM