Page usage Code:
<script src= "@Url. Content (" ~/content/bootstrap/js/bootstrap.min.js ")" ></script> < link href= "@ Url.content ("~/content/bootstrap/css/bootstrap.min.css") "rel=" stylesheet "media=" screen "/>2.angularjs< Script src= "@Url. Content (" ~/scripts/angular.min.js ") ></script>
<script type= "Text/javascript" >
var app = Angular.module ("ControlState", []); App.controller ("Home/login",function ($scope, $window) {$scope. Login =function (user) {var url=The @Url. Action ("Login"," Home")"; $.post (Url,user,function (ret) {if (ret=="False") {art.dialog.tips (' User name or password is wrong, please re-enter! ‘,1.5); $(' Form ') [0].reset (); $(' Form input ') [0].focus (); }else{if (user. username== "Index"; else location=
3.page OutPublic ActionResult MessageBox (Int?id) {int pageid=1;if (ID. HasValue) {Pageid=id. Value; }var list=dbfactory.getentities<message> (MessageTable.MessageToUserID.Equal (Systemglobaldata.current_ USERID). and (MessageTable.Deleted.Equal (0))); var count=dbfactory.getint32count (MessageTable.MessageToUserID.Equal (Systemglobaldata.current_userid). and (MessageTable.Deleted.Equal (0))); pagedlist<message> plist=New pagedlist<message> (List,pageid,5); return View (pList); }
Front-end Code
View Code
4. Permissions role Validation
Using System;Using System.Collections.Generic;Using System.Linq;Using System.Web;Using SYSTEM.WEB.MVC;Using System.Xml.Linq;
Using Moon.orm;Using Mynorthdb;
Namespace Razor.moon {///<summary>///Description of Checkloginattribute.///</summary> PublicClass Custemerauthenattribute:authorizeattribute {PublicNewString[] Actionroles {GetSet }ProtectedOverrideBOOL Authorizecore (HttpContextBase HttpContext) {if (HttpContext = =NULL) {ThrowNew ArgumentNullException ("HttpContext"); }if (!httpcontext.user.identity.isauthenticated) {ReturnFalse }if (Actionroles = =NULL) {ReturnTrue }if (actionroles.length = =0) {ReturnTrue }if (Actionroles.contains (HttpContext.User.Identity.Name)) {ReturnTrue }ReturnFalse }ProtectedOverridevoid Handleunauthorizedrequest (AuthorizationContext filtercontext) {var request=filtercontext.httpcontext.request;String url=request.url.scheme+"://"+request.url.authority+"/home/login"; Filtercontext.result =New Redirectresult (URL); }PublicOverridevoid Onauthorization (System.Web.Mvc.AuthorizationContext filtercontext) {string controllername = FilterContext.ActionDescriptor.ControllerDescriptor.ControllerName;string actionname = FilterContext.ActionDescriptor.ActionName;String roles = Actionrolemanager.getactionroles (ActionName, controllername);if (! String. Isnullorwhitespace (roles)) {this . actionroles = roles. Split (new string[] { ","}, Stringsplitoptions.removeemptyentries); } base. Onauthorization (Filtercontext); } } }5.
6. Project Download
http://files.cnblogs.com/humble/%E9%A1%B9%E7%9B%AE%E5%8F%8A%E6%95%B0%E6%8D%AE%E5%BA%93.7z
Http://www.cnblogs.com/humble/p/3149734.html
bootstrap+angularjs+mvc3+ Paging Technology + role Authorization verification system