ASPNET MVC3技术要点(17)
发布时间:2021-06-06
发布时间:2021-06-06
ASPNET MVC3技术要点
return View(); } [HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl) {
if (ModelState.IsValid) {
FormsAuthentication.SetAuthCookie(erName, model.RememberMe); }
return RedirectToAction("Index", "Home"); }
public ActionResult LogOff() {
FormsAuthentication.SignOut();
return RedirectToAction("Index", "Home"); } } }
及LogOn.cshtml
@model ControllersAndActions.Models.LogOnModel @{
ViewBag.Title = "Admin: Log In"; }
<h1>Log In</h1>
<p>Please log in to access the administrative area:</p> @using(Html.BeginForm()) { @Html.ValidationSummary(true) @Html.EditorForModel()
<p><input type="submit" value="Log in" /></p> }
这里使用LogOnModel
using ponentModel.DataAnnotations; namespace ControllersAndActions.Models {
public class LogOnModel {
[Required]
[Display(Name = "User name")] public string UserName { get; set; }
[Required]
[DataType(DataType.Password)] [Display(Name = "Password")] public string Password { get; set; }
上一篇:S3C44B0 学习板使用指南
下一篇:朗文交互英语第二级A2答案