Controllers/AccountController.cs

(开头部分) 5KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Security;
using MVCOnlineCount.Models;
//www.51aspx.com
namespace MVCOnlineCount.Controllers
{
	public class AccountController : Controller
	{

		//
		// GET: /Account/LogOn

		public ActionResult LogOn()
		{
			return View();
		}

		//
		// POST: /Account/LogOn

		[HttpPost]
		public ActionResult LogOn(LogOnModel model, string returnUrl)
		{
			if (ModelState.IsValid)  ////简单的验证即为登录有效
			{
				//会话标示写入Session值,并设置有效时间
				System.Web.HttpContext.Current.Session.Add("SessionID", Guid.NewGuid().ToString());
				System.Web.HttpContext.Current.Session.Timeout = 5;
				///登录成功,对在线人数全局变量进行加1处理
				System.Web.HttpContext.Current.Application["count"] = Convert.ToInt32(System.Web.HttpContext.Current.Application["count"]) + 1;
				if (Request.QueryString["ReturnUrl"] != null)
				{
					FormsAuthentication.RedirectFromLoginPage(model.UserName, false);
				}
				else
				{
					FormsAuthentication.SetAuthCookie(model.UserName, false);
					return RedirectToAction("Index", "Home");
				}
			}
			return View(model);
		}

		//
		// GET: /Account/LogOff

		public ActionResult LogOff()
		{
			FormsAuthentication.SignOut();
			System.Web.HttpContext.Current.Session.Abandon();//取消当前会话
			return RedirectToAction("Index", "Home");
		}

		public void ClosePage()
		{
后面还有 133 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。