如何使用 ASP.NET MembershipProvider 来继承用户?会话数据存储在 ColdFusion 设置的 cookie 中?

发布于 2024-10-17 18:39:06 字数 835 浏览 5 评论 0原文

我正在努力向现有网站添加新的网络应用程序。我被指示在 ASP.NET 中编写 Web 应用程序。现有网站是用 ColdFusion 编写的。在大多数情况下,ASP.NET Web 应用程序是完全独立的,但它需要以一种重要的方式与 ColdFusion 代码进行交互 - 如果有人登录到 ColdFusion 站点,我们不希望他们必须登录当访问 ASP.NET 页面时再次出现。

当有人登录 ColdFusion 站点时,他们的用户名以及可以在我们的数据库中查找的登录令牌存储在 cookie 中。我的 .NET 有点生疏,所以我很难想象 ASP.NET 代码应该如何使用这些数据。我已经编写了一个简单的 MembershipProvider,可用于使用与 ColdFusion 代码共享的现有数据库表中的数据登录/注销 ASP.NET 应用程序。

我想知道的是 - 如何确保 ASP.NET 应用程序检测到 ColdFusion 应用程序设置的 cookie(我想它们会被发送到 ASP.NET 页面,因为所有内容都托管在一个域上) ,并使用 cookie 中提供的凭据使用 MembershipProvider 和表单身份验证自动登录用户?我正在考虑在 Global.asax 文件中放置某种 cookie 检查和登录功能,设置为每个页面运行每个页面加载......但这似乎有点笨拙。另外,人们仍然使用 Global.asax 文件吗?我原以为有一种更现代的方法......另外,我如何使用表单身份验证和自定义会员资格提供商手动登录某人?目前,我的代码允许用户使用提供的登录控件登录,但我不确定如何在用户无需执行任何操作的情况下登录用户。

预先感谢您的任何帮助。浏览 MembershipProvider 教程和 MSDN 文档,在我看来,答案应该就在我眼前,但由于某种原因我就是看不到它。可能咖啡不够……

I'm working on adding a new webapp to an existing website. I've been directed to write the webapp in ASP.NET. The existing website is written in ColdFusion. For the most part, the ASP.NET webapp is completely stand-alone, but it needs to interact with the ColdFusion code in one important way - if somebody logs in to the ColdFusion site, we don't want them to have to log in again when visiting an ASP.NET page.

When someone logs in to the ColdFusion site, their username is stored in a cookie, along with a login token that can be looked up in our database. My .NET is a little rusty, so I'm having trouble visualizing how the ASP.NET code should use this data. I've already written a simple MembershipProvider that can be used to log in/out out the ASP.NET app using the data in our existing database tables, which are shared with the ColdFusion code.

What I'd like to know is - how can I make sure the ASP.NET app detects the cookies set by the ColdFusion app (I imagine they'd be sent to the ASP.NET pages, since everything is hosted on one domain), and automatically logs the user in using the MembershipProvider and Forms Authentication, using the credentials supplied in the cookie? I'm thinking that putting some kind of cookie check and log in function in the Global.asax file, set to run every page load for every page... but that seems kind of clunky. Also, do people still use the Global.asax file anyway? I had thought there was a more modern method.... Also, how can I manually log someone in using Forms Authentication and a custom membership provider? Currently my code allows the user to log in using the provided login control, but I'm not sure how to log the user in without them having to do anything.

Thanks in advance for any help. Looking over the MembershipProvider tutorials and the MSDN documentation it seems to me like the answer should be staring me in the face, but for some reason I just can't see it. Maybe not enough coffee....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

隱形的亼 2024-10-24 18:39:07

我通常是一名 CF 开发人员,但最近我们必须与 .NET 应用程序进行一些集成,我们的方法是将 CF 和 .NET 会话分开,但确保登录发生在两者上 因此,当用户从一个移动到另一个时,他们仍然处于登录状态。

那么,当您使用 CF 应用程序登录时,是否有一种方法可以通过请求登录用户的 ASP.NET 应用程序来访问您的 ASP.NET 应用程序?也许您可以在页面上放置一个 iframe,当 CF 登录完成后可以加载该 iframe,其中包含 .NET 应用程序的登录服务?

这样,您就不必担心一个应用程序服务器读取另一个应用程序服务器的 cookie,而是有两组 cookie,一组用于 ASP,一组用于 CF。

希望有帮助!

I'm a CF developer ususally, but we had to do some integration with a .NET application recently and the way we approached it was to keep the CF and .NET sessions separate but ensure that login happened on both so when the user moved from one to the other they were still logged in.

So is there perhaps a way for you to hit your ASP.NET application with a request to login a user when you login using the CF application? Perhaps you could have an iframe on the page that you can load when the CF login is complete that holds a login service for the .NET app?

This way you would not need to worry about one app server reading the other app server's cookies, instead there would be two sets of cookies, one for ASP and one for CF.

Hope that helps!

看轻我的陪伴 2024-10-24 18:39:07

我的处理方式是,我将有一个特定的页面作为 CF 和 .NET 层之间的联络人。该页面将实现您的业务层,并仅检查 Cookie 是否存在,如果存在,则将其读入,进行查找并登录用户或需要完成的任何业务逻辑。您将如何完成登录/身份验证,这完全取决于您的登录/身份验证代码。

我可以提供的唯一链接是 ASP.net 中 cookie 的基础

http://msdn.microsoft.com/en-us/library/aa289495(v=vs.71).aspx

编辑:找到另一个可能有用的链接。
http://www.aspnettutorials.com/tutorials/network/cookies-csharp.aspx

The way I would approach it, is I would have a specific page that acts as a liaison between the CF and .NET layer. That page would implement your business layer and just check to see if the Cookie is there, if so read it in, do the lookup and login the user or whatever business logic that needs to be done. How would you accomplish the login/authentication, well that’s all based on your login/authentication code.

The only link I can offer is the basic of cookies in ASP.net

http://msdn.microsoft.com/en-us/library/aa289495(v=vs.71).aspx

Edit: found another link that might be helpful.
http://www.aspnettutorials.com/tutorials/network/cookies-csharp.aspx

雪若未夕 2024-10-24 18:39:06

不确定这是否是您要查找的内容:

FormsAuthentication.SetAuthCookie("the username goes here",false); 

参考

Not sure if this is what you're looking for:

FormsAuthentication.SetAuthCookie("the username goes here",false); 

Reference

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文