Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to authorise user from the forum's main page?
    primarykey
    data
    text
    <p>I'm trying to implement a simple blog, which contains topics</p> <p><strong>models/Topic.cs</strong></p> <pre><code>public class Topic { public int ID {get; set;} [StringLength(50)] [RequiredAttribute(ErrorMessage = "*")] public string Title {get; set;} [StringLength(1024)] [RequiredAttribute(ErrorMessage = "*")] public string Body { get; set; } public int CommentsCount { get; set; } public DateTime TimeLastUpdated { get; set; } public int AuthorID { get; set; } public virtual List&lt;Comment&gt; commentsList { get; set; } } </code></pre> <p>Main Page looks like a list of topics. </p> <p><strong>Controllers/HomeController.cs</strong></p> <pre><code>public class HomeController : Controller private ContentStorage db = new ContentStorage(); public ViewResult Index() { // Topics = DbSet&lt;Topic&gt; Topics { get; set; } return View(db.Topics.ToList()); } [HttpPost] public void LogIn(string login, string password) { int i; i = 10; } } </code></pre> <p>Main page's view is very simple.</p> <p><strong>Views/Home/Index</strong></p> <pre><code>@model IEnumerable&lt;MvcSimpleBlog.Models.Topic&gt; ... &lt;table width="95%" height="86" border="0"&gt; &lt;tr&gt; &lt;td width="45%" valign = "bottom" &gt;Login:&lt;/td&gt; &lt;td width="45%" valign = "bottom" &gt;Password:&lt;/td&gt; &lt;td width="10%"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="45%"&gt;&lt;p&gt; &lt;input type="text" name="login" /&gt; &lt;/p&gt;&lt;/td&gt; &lt;td width="45%"&gt;&lt;p&gt;&lt;input type="password" name="password" /&gt;&lt;/p&gt;&lt;/td&gt; &lt;td width="10%" align = "left"&gt; @using (Html.BeginForm("LogIn", "Home")) { &lt;input type = "submit" value = "Enter" /&gt; } &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="45%" valign = "top" &gt;@Html.ActionLink("Register", "Register", "Account")&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>How could i pass the values from edit boxes in the View to the HomeController method? The method "LogIn" was supposed to receive data from the view, call the "Account" controller, passing user's login and password to it. An "Account" controller shoud validate this user and redirect browser to the main page with topics.</p> <p>But i can't access login and password edit boxes in the view... and i really don't know what should i do, and is my model correct</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.
    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