首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏张善友的专栏

    WCF服务中操作FormsAuthentication的Cookie

    在asp.net 应用程序和WCF服务之间共享FormsAuthentication,默认是不支持的,设置一下非常的简单,只需要两步就可以了: 1、在web.config的system.serviceModel formsConfig.Timeout.TotalMinutes),    // 失效时间 true,"");    // 用户数据  //加密票 string encryptedTicket = FormsAuthentication.Encrypt (formAuthTicket); // 以加密票的密文存入Cookie                HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName ;                authCookie.Secure = FormsAuthentication.RequireSSL; if (FormsAuthentication.CookieDomain = null)                {                    authCookie.Domain = FormsAuthentication.CookieDomain;                

    86250发布于 2018-01-19
  • 来自专栏程序随笔

    ASP.NET底层封装HttpModule实例---FormsAuthentication类的分析

    ) { ticket = FormsAuthentication.RenewTicketIfOld(tOld); ticket.IsPersistent, ticket.UserData, "/"); } string cookieValue = FormsAuthentication.Encrypt = null) { cookie = e.Context.Request.Cookies[FormsAuthentication.FormsCookieName ; cookie.HttpOnly = true; if (FormsAuthentication.CookieDomain = null) { cookie.Domain = FormsAuthentication.CookieDomain

    62510编辑于 2023-10-18
  • 来自专栏大嘴说编程

    关于ASP.NET MVC中使用Forms验证的问题

    如果用户验证成功,你只需要告诉ASP.NET架构验证成功(通过调用FormsAuthentication类的一个方法),运行库会自动设置验证cookie(实际上包含了票据)并将用户转到原先请求的页面。 private void CreateToken(Models.User user) { string json = JsonConvert.SerializeObject(user); FormsAuthentication.SetAuthCookie (user.UserName.Trim(), true, FormsAuthentication.FormsCookiePath); FormsAuthenticationTicket Ticket , FormsAuthentication.Encrypt(Ticket)); } 其中Biz126.Cache.SetCookies.AddCookie是我自己封装的保存Cookie方法。 ];//获取cookie FormsAuthenticationTicket Ticket = FormsAuthentication.Decrypt(authCookie.Value

    1.9K20发布于 2019-03-21
  • 来自专栏阿炬.NET

    登陆后设置cookie的方法

    public void SetCookie(string userName, string role,string cookieValueName) {FormsAuthentication.FormsCookieName userName, System.DateTime.Now.AddMinutes(30),DateTime.Now, false, role); string encryptTick=FormsAuthentication.Encrypt HttpContext.Current.Response.Cookies.Add(myCookie); } 这是我登陆后设置cookie的方法,本来cookieValueName是用FormsAuthentication.FormsCookieName

    1.7K70发布于 2018-05-11
  • 来自专栏阿林前端开发攻城狮

    C#封装的DES加密、解密类代码

    Encoding.Default.GetBytes(Text); des.Key = ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile sKey, "md5").Substring(0, 8)); des.IV = ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile inputByteArray[x]=(byte)i; } des.Key = ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile sKey, "md5").Substring(0, 8)); des.IV = ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile

    1.6K40发布于 2021-11-03
  • 来自专栏远在上海

    C#开发中Windows域认证登录2(扩展吉日嘎拉GPM系统)

    domain, string lDAP, string userName, string password, string permissionCode, bool persistCookie, bool formsAuthentication 权限编号</param>
            /// <param name="persistCookie">是否保存密码</param>
            /// <param name="<em>formsAuthentication</em> domain, string lDAP, string userName, string password, string permissionCode, bool persistCookie, bool <em>formsAuthentication</em> RemoveUserCookie();<br/>                            }<br/>                            LogOn(userInfo, <em>formsAuthentication</em>

    75210发布于 2019-02-26
  • 来自专栏技术博客

    Asp.Net MVC3.0网站统计登录认证的在线人数

    = null) { FormsAuthentication.RedirectFromLoginPage(model.UserName , false); } else { FormsAuthentication.SetAuthCookie 第四步:对于登出的Action进行处理如下: public ActionResult LogOff() { FormsAuthentication.SignOut } } </script> 此时关闭的情况调用的Action如下:  public void ClosePage() { FormsAuthentication.SignOut

    1.4K20发布于 2018-08-31
  • 来自专栏C#

    DotNet中几种常用的加密算法

    Upper32(string s) { var hashPasswordForStoringInConfigFile = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile Lower32(string s) { var hashPasswordForStoringInConfigFile = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile Upper16(string s) { var hashPasswordForStoringInConfigFile = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile Lower16(string s) { var hashPasswordForStoringInConfigFile = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile

    91870发布于 2018-01-04
  • 来自专栏菩提树下的杨过

    关于Membership/Role您可能不知道的细节

    对了,不信把Cookie禁用掉(建议用最BT的办法,把Documents and Settings\Administrator\Cookies目录设置为任何用户都无权读取),然后就登录不了系统 3.除了FormsAuthentication.SignOut 从2中很容易想到,只要能找到特定用户的客户端Cookie,并使其过期就可以了,看下面的代码: HttpCookie _cookie = FormsAuthentication.GetAuthCookie

    748100发布于 2018-01-23
  • 来自专栏有刻

    ASP.NET Core 和 ASP.NET Framework 共享 Identity 身份验证

    .net core 是非对称加密,所以要在 .net core 中动手的话必须要对 .net core 默认的加密和解密操作进行拦截,如果可行的话最好的方案应该是将 .net framework 的 FormsAuthentication ,剪不断理还乱,github 找到其开源地址:https://github.com/Microsoft/referencesource/blob/master/System.Web/Security/FormsAuthentication.cs Route("getMyTicket")] public IHttpActionResult GetMyTicket(string cookie) { var formsAuthTicket = FormsAuthentication.Decrypt RedirectToAction("Index"); } webapi 获取 cookie [Route("getMyCookie")] public string GetMyCookie(string name) { FormsAuthentication.SetAuthCookie (name, false); return FormsAuthentication.GetAuthCookie(name, false).Value; } 其余代码不用做任何更改,ok,我们来测试一下

    2.6K70发布于 2018-05-14
  • 来自专栏渗透测试红队专栏

    记一次.Net代码审计-通过machineKey伪造任意用户身份

    是的,这套系统使用了微软FormsAuthentication类作为身份认证。 FormsAuthentication类提供了一个 Encrypt 方法,用于创建一个字符串值,该字符串值可以存储在 cookie 中,也可以存储在 URL 中 FormsAuthenticationTicket FormsAuthentication类还提供了一 个Decrypt 方法,用于 FormsAuthenticationTicket 根据从 forms 身份验证 cookie 或 URL 检索到的加密的身份验证票证来创建对象

    1.9K30发布于 2021-04-13
  • 来自专栏飞扬的花生

    基于ASP.MVC票据FormsAuthenticationTicket身份认证

    Newtonsoft.Json.JsonConvert.SerializeObject(admin)); //数据加密 string enyTicket = FormsAuthentication.Encrypt AdminLoginInfo mode = null; try { FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt

    1.4K70发布于 2018-01-18
  • 来自专栏圣杰的专栏

    Asp.net mvc 知多少(八)

    当SetAuthCookie()或RedirectFromLoginPage()被调用时FormsAuthentication类自动创建认证Cookie。 DateTime.Now.AddMinutes(30), // value of time out property false, // Value of IsPersistent property String.Empty, FormsAuthentication.FormsCookiePath ); 然后就可以使用FormsAuthentication类的Encrypt方法来加密ticket。 string encryptedTicket = FormsAuthentication.Encrypt(ticket); Q85.

    1.9K90发布于 2018-01-11
  • 来自专栏技术小讲堂

    ASP.NET AJAX(10)__Authentication ServiceAuthentication ServiceAuthentication Service属性Authentication

    WebService,则可能被恶意用户利用,造成性能以及安全性的问题,所以我们需要使用一些验证方式来保护WebService,最常见方式就是Forms Authentication,这也是一种用法很简单的方式 一个使用FormsAuthentication ("xiaoyaojian", false);//使用FormsAuthentication,登陆Username为xiaoyaojian的用户,false表示不使用持久化的Cookie } protected void btnLogout_Click(object sender, EventArgs e) { FormsAuthentication.SignOut Service的功能就是为我们提供一种以AJAX方式登陆和注销用户的功能,如果我们自己来实现,就会使用客户端调用WebService来实现这样的功能,而它给我们提供了更多的,比如跳转之类,实际上他的内部还是通过FormsAuthentication ,点击Login,弹出成功的提示,但是我们点击GetRandom,是不会出现随机数的,因为我们没有执行FormsAuthentication.setAuthCookie,这也正好证明了我们扩展的AuthenticationService

    2.1K90发布于 2018-03-07
  • 来自专栏jessetalks

    Membership三步曲之入门篇 - Membership基础示例

    的登录 User.Identity.IsAuthenticated 将设置为True // User.Identity.Name 会设置成我们下面的UserName FormsAuthentication.SetAuthCookie = null) { //注册完成之后直接登录用户 FormsAuthentication.SetAuthCookie return View(model); } 登出相关代码 [HttpPost] [ValidateAntiForgeryToken] public ActionResult LogOff() { FormsAuthentication.SignOut Index", "Home"); } 修改密码相关代码 [HttpPost] [ValidateAntiForgeryToken] public ActionResult LogOff() { FormsAuthentication.SignOut

    1.4K60发布于 2018-03-14
  • 来自专栏C#

    DotNet加密方式解析--散列加密

    Upper32(string s) { var hashPasswordForStoringInConfigFile = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile Lower32(string s) { var hashPasswordForStoringInConfigFile = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile Upper16(string s) { var hashPasswordForStoringInConfigFile = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile Lower16(string s) { var hashPasswordForStoringInConfigFile = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile

    1.5K80发布于 2018-01-04
  • 来自专栏葡萄城控件技术团队

    七天学会ASP.NET MVC (四)——用户授权认证问题

    FormsAuthentication.SetAuthCookie是必须写的吗? 是必须写的。让我们了解一些小的工作细节。 客户端通过浏览器给服务器发送请求。 FormsAuthentication.SetAuthCookie将添加 “Authentication”特殊的Cookie来响应。 是否意味着没有Cookies,FormsAuthentication 将不会有作用? 不是的,可以使用URI代替Cookie。 FormsAuthentication.SetAuthCookie中第二个参数”false“表示什么? false决定了是否创建永久有用的Cookie。 AuthenticationController 添加新的Logout action方法: 1: public ActionResult Logout() 2: { 3: FormsAuthentication.SignOut

    10K50发布于 2018-01-10
  • 来自专栏技术小讲堂

    ASP.NET AJAX(9)__Profile Service什么是ASP.NET Profile如何使用ASP.NET ProfileProfile ServiceProfile Service预

    ; FormsAuthentication.SignOut();//注销用户 } else { this.lblMessage.Text ; FormsAuthentication.SetAuthCookie(this.txtUsername.Text, false);//使用户登陆 } } e) { } protected void btnLogin_Click(object sender, EventArgs e) { FormsAuthentication.SetAuthCookie this.txtUserName.Text, false); } protected void btnLogout_Click(object sender, EventArgs e) { FormsAuthentication.SignOut

    1.6K90发布于 2018-03-07
  • 来自专栏更流畅、简洁的软件开发方式

    【自然框架】开源社区活动,会员注册的第一份代码!

    puser.Email = TBEmail.Text;             puser.UserCode = TBCode.Text;             puser.UserPassword = FormsAuthentication.HashPasswordForStoringInConfigFile

    92690发布于 2018-02-26
  • 来自专栏飞扬的花生

    ASP.MVC 基于AuthorizeAttribute权限设计案例

    Newtonsoft.Json.JsonConvert.SerializeObject(new {name="test"})); string ticString = FormsAuthentication.Encrypt

    1.9K70发布于 2018-01-18
领券