Easyui + asp.net MVC 系列教程 第19-23 节 完成注销 登录限制过滤 添加用户
前面视频 文章地址
如果用户没有登录 就访问我们的管理页面 那么 直接跳转到登录 当然 可以可以给一个中间的页面 对用户进行友好的提示
我们首先找到 管理页的action
public ActionResult Index()
{
return View();
}
我们编写一个过滤器 要继承和实现一个接口
public class CheckLoginFilter : FilterAttribute, IActionFilter
{ public void OnActionExecuted(ActionExecutedContext filterContext)
{
if (HttpContext.Current.Session["user"] == null)
{
filterContext.HttpContext.Response.Write("-1");
}
} public void OnActionExecuting(ActionExecutingContext filterContext)
{
if (HttpContext.Current.Session["user"] == null)
{
//filterContext.HttpContext.Response.Write("-1");
try
{
filterContext.Result = new RedirectResult("/Account/Login");
}
catch (Exception)
{
filterContext.Result = new RedirectResult("/Common/Error");
}
}
}
}
然后 为管理员打上标记
[CheckLoginFilter()]
public ActionResult Index()
{
return View();
}
用户添加页面的设计
<div id="tb" style="padding:5px;height:auto">
<div style="margin-bottom:5px">
<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true"></a>
<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true"></a>
<a href="#" class="easyui-linkbutton" iconCls="icon-save" plain="true"></a>
<a href="#" class="easyui-linkbutton" iconCls="icon-cut" plain="true"></a>
<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true"></a>
</div>
<div>
用户名: <input type="text" id="name" style="width:80px">
密 码: <input type="text" id="pwd" style="width:80px">
技 术:
<select id="tec" class="easyui-combobox" panelHeight="auto" style="width:100px">
<option value="java">Java</option>
<option value="c">C</option>
<option value="basic">Basic</option>
<option value="perl">Perl</option>
<option value="python">Python</option>
</select>
<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="AddUser();">添加</a>
</div>
</div>
添加提交事件
function AddUser() {
//$.messager.alert('Warning', '你真的添加吗!');
var name = $('#name').val();
var pwd = $('#pwd').val();
var tec = $('#tec').val();
if (name == '' || pwd == '') {
$.messager.alert('Warning', '用户名或者密码为空!');
}
else {
$.post("/Account/AddUser", { name: name, name: pwd },
function (data) {
//alert("Data Loaded: " + data);
if (data == '') {
$.messager.alert('Warning', '添加失败!');
}
else {
$.messager.alert('Warning', '添加成功!');
}
});
}
}
高清录屏下载地址
18-19节
http://pan.baidu.com/share/link?shareid=1882807484&uk=1731339785
20节
http://pan.baidu.com/share/link?shareid=473445811&uk=36858893
21-23节
http://pan.baidu.com/share/link?shareid=1857442884&uk=1731339785
Easyui + asp.net MVC 系列教程 第19-23 节 完成注销 登录限制过滤 添加用户的更多相关文章
- Easyui + asp.net MVC 系列教程 完成登录
Easyui + asp.net MVC 系列教程 第09-17 节 完成登录 高清录制 前面八节 在这里 Easyui + asp.net mvc + sqlite 开发教程(录屏)适合入门 在接下 ...
- Easyui + asp.net MVC 系列教程 第09-17 节 完成登录 高清录制
前面八节 在这里 Easyui + asp.net mvc + sqlite 开发教程(录屏)适合入门 在接下来的 几节里面 我们完成登录功能 打开页面 首先进入登录页面 只有登录成功了 才能进入管理 ...
- Easyui + asp.net mvc + sqlite 开发教程(录屏)适合入门
Easyui + asp.net mvc + sqlite 开发教程(录屏)适合入门 第一节: 前言(技术简介) EasyUI 是一套 js的前端框架 利用它可以快速的开发出好看的 前端系统 web ...
- 【ASP.NET Identity系列教程(一)】ASP.NET Identity入门
注:本文是[ASP.NET Identity系列教程]的第一篇.本系列教程详细.完整.深入地介绍了微软的ASP.NET Identity技术,描述了如何运用ASP.NET Identity实现应用程序 ...
- 【ASP.NET Identity系列教程(二)】运用ASP.NET Identity
注:本文是[ASP.NET Identity系列教程]的第二篇.本系列教程详细.完整.深入地介绍了微软的ASP.NET Identity技术,描述了如何运用ASP.NET Identity实现应用程序 ...
- 【ASP.NET Identity系列教程(三)】Identity高级技术
注:本文是[ASP.NET Identity系列教程]的第三篇.本系列教程详细.完整.深入地介绍了微软的ASP.NET Identity技术,描述了如何运用ASP.NET Identity实现应用程序 ...
- 【转】ASP.NET MVC 入门教程列表
ASP.NET MVC小论 2008-12-04 11:11 by T2噬菌体, 8052 visits, 网摘, 收藏, 编辑 摘要:ASP.NET MVC作为微软官方的.NET平台下MVC解决方案 ...
- 【ASP.NET MVC系列】浅谈ASP.NET MVC 路由
ASP.NET MVC系列文章 [01]浅谈Google Chrome浏览器(理论篇) [02]浅谈Google Chrome浏览器(操作篇)(上) [03]浅谈Google Chrome浏览器(操作 ...
- ASP.NET Identity系列教程(目录)
$(document).ready(function(){ $("#hide").click(function(){ $(".en").hide(); }); ...
随机推荐
- Cantor展开式
X=an*(n-1)!+an-1*(n-2)!+...+ai*(i-1)!+...+a2*1!+a1*0! 其中,a为整数,并且0<=ai<i(1<=i<=n).这就是康托展开 ...
- go语言之进阶篇关闭channel
1.关闭channel package main import ( "fmt" ) func main() { ch := make(chan int) //创建一个无缓存chan ...
- 排序算法的实现(归并,快排,堆排,希尔排序 O(N*log(N)))
今天跟着左老师的视频,理解了四种复杂度为 O(N*log(N))的排序算法,以前也理解过过程,今天根据实际的代码,感觉基本的算法还是很简单的,只是自己写的时候可能一些边界条件,循环控制条件把握不好. ...
- Gray Code leetcode java
题目: The gray code is a binary numeral system where two successive values differ in only one bit. Giv ...
- ORM数据库框架 LitePal SQLite MD
Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...
- 【Javascript设计模式1】-单例模式
<parctical common lisp>的作者曾说,如果你需要一种模式,那一定是哪里出了问题.他所说的问题是指因为语言的天生缺陷,不得不去寻求和总结一种通用的解决方案. 不管是弱类型 ...
- 【转】字符编码笔记:ASCII,Unicode 和 UTF-8
原文:http://www.ruanyifeng.com/blog/2007/10/ascii_unicode_and_utf-8.html https://www.key-shortcut.com/ ...
- Spring(九):Spring配置Bean(二)自动装配的模式、Bean之间的关系
XML配置里的Bean自动装配 Spring IOC容器可以自动装配Bean,需要做的仅仅是在<bean>的autowire属性里指定自动装配的模式,模式包含:byType,byName, ...
- sublime同步文件与siderbar
有时候,打开了sider bar,想和Eclipse.idea一样,每打开一个tab,就可以在左侧的sider bar 目录上面看到我当前的位置,于是找到了一个插件. SyncedSideBar 安装 ...
- [Algorithm] How many times is a sorted array rotated?
Given a sorted array, for example: // [2,5,6,8,11,12,15,18] Then we rotated it 1 time, it becomes: / ...