Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I display the current user logged in against the database?
    primarykey
    data
    text
    <p>I have created a website with a custom login to my database using SQL Server and would like to know how to display the text of the user logged in. Currently it is showing the users "Login" beside the word welcome but I would rather show the users actual name. I am new to MVC3 and would like to know how to change the following line in the _LogOnPartial.cshtml to display a field from my database "AgentFirstName" </p> <pre><code>&lt;text&gt;Welcome &lt;strong&gt;@User.Identity.Name&lt;/strong&gt; </code></pre> <p>Here is my AccountControler</p> <pre><code>[HttpPost] public ActionResult LogOn(LogOnModel model) { if (ModelState.IsValid) { if (DAL.MyWebsiteContextClass.userIsValid(model.AgentLogin, model.AgentPassword)) { FormsAuthentication.SetAuthCookie(model.AgentLogin, false); return RedirectToAction("Index", "Home"); } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } return View(model); } </code></pre> <p>Here is my agents model</p> <pre><code>public class Agents { public virtual int ID { get; set; } public virtual string AgentFirstName { get; set; } public virtual string AgentLastName { get; set; } public virtual string AgentLogin { get; set; } public virtual string AgentPassword{ get; set; } </code></pre> <p>With a web config set like this</p> <pre><code>&lt;add name="MyWebsiteContextClass" connectionString="Data Source=My-SQL\SQLEXPRESS; Initial Catalog=MyWebsite; Persist Security Info=True;User ID=sa;Password=password" providerName="System.Data.SqlClient"/&gt; </code></pre> <p>And this is in my context Class</p> <pre><code>public DbSet&lt;Agents&gt; AgentsPkg { get; set; } </code></pre> <p>Unfortunatley I do not know what else you might need to help me but if you need anything please ask and I will do what I can. Thanks for your help</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload