首页
学习
活动
专区
圈层
工具
发布

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;

84950
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    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

    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
    领券