web.fonfig<authentication mode="Forms">
<forms name=".fuck" path="/" loginUrl="*.aspx" protection="All" />
</authentication>
<authorization>
<deny users="?"/>
</authorization>
<forms name=".fuck" path="/" loginUrl="*.aspx" protection="All" />
</authentication>
<authorization>
<deny users="?"/>
</authorization>
解决方案 »
- TextChanged怎么使用?
- 我用asp.net做文件上传 在点“开始上传”时在label控件不显示需要的内容?
- 还是上次SQL语句,有些bug,不会修改了,坐等啊!!!这破脑子。。
- oracle 中的 select 怎么用?
- 请各位帮忙给鉴定一下,谢谢了
- 问个最基础的问题
- 如何通过父页面,取到iframe中<asp:table>控件的值
- 在发数据显示问题。马上结帐,
- 开发在线考试系统时候,如果是选择提,最后可以给用户打分数,如果是填空题,怎么打分呢??总不能每一个字都比较吧???
- 请问如何运行已下载的ASP.net的源码程序!
- 求助 关于字符串分割
- 由谁能做到http://www.dbstep.com/Products/Demo/iWebOffice2000/Ocxasp/DocumentList.asp这个,源代码可以购买!
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName,FormsAuthentication.Encrypt(ticket) );
cookie.Expires=DateTime.Now.AddMinutes(60);//过期时间,这里60为分钟数
Response.Cookies.Add(cookie);
//取用户名
User.Identity.Name
//注销用户
//将cookies设置为过去的时间,使其失效,从而进行Forms验证
HttpCookie cookie = new HttpCookie(".fuck");
cookie.Expires=Convert.ToDateTime("1980-2-3");
Response.AppendCookie(cookie);
- Role-based Security with Forms Authentication
http://www.codeproject.com/aspnet/formsroleauth.asp
string role=reader.GetInt32(0).ToString();
//产生 Ticket
FormsAuthenticationTicket userTicket=new FormsAuthenticationTicket(1,uid,
DateTime.Now,DateTime.Now.AddMinutes(30),true,role,"login");//加密票据
string hashUserTicket=FormsAuthentication.Encrypt(userTicket);
//产生新的Cookie
HttpCookie userCookie=new HttpCookie("login",hashUserTicket);
Response.Cookies.Add(userCookie);
//返回用户原来返回的页面
Context.Response.Redirect(Context.Request["ReturnUrl"],true);global.asax.csprotected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
HttpApplication app=(HttpApplication)sender;
HttpContext ctx=app.Context;
//如果验证成功
if(ctx.Request.IsAuthenticated==true)
{
FormsIdentity typeID=(FormsIdentity)ctx.User.Identity;
FormsAuthenticationTicket ticket=typeID.Ticket;
string []role=ticket.UserData.Split(',');
ctx.User=new GenericPrincipal(typeID,role);
}
}文件夹底下的web.config的培植
<authorization>
<allow roles="1"/>
<deny users="*"/>
</authorization>我的权限 role 有三种, 为这三个权限建立三个 文件夹要 导入的命名空间using System.Web.Security;
using System.Security.Principal;
web.config 的配置
<authentication mode="Forms">
<forms name="login" path="/" loginUrl="login.aspx">
<credentials passwordFormat="Clear">
<user name="guest" password="guest"/>
</credentials>
</forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>起始页为 default.aspx, 登陆页面为login.aspx ;