通过 RIA 服务在 asp.net mvc 3 网站和 silverlight 4 业务应用程序之间共享身份验证

发布于 2024-11-17 18:22:27 字数 609 浏览 1 评论 0原文

我有一个 asp.net MVC 3 网站和一个 silverlight 4 业务应用程序。他们都分别使用 asp 会员系统(通过 RIA 服务的 silverlight 应用程序)。我可以单独运行它们并创建用户或从网站或 Silverlight 业务应用程序登录。在这方面,它们还共享相同的数据库,因此从任一数据库注册用户都将转到同一数据库中的相同表。

我想做的是将 Silverlight 业务应用程序托管在 MVC 3 网站中,并在两者之间共享身份验证。这意味着该网站将有一个启动 silverlight 应用程序的链接,因此如果我通过该网站登录并启动 silverlight 应用程序,我希望 silverlight 应用程序知道我已经登录。

或者,我希望能够将 silverlight 应用程序作为独立的桌面应用程序启动,并通过 RIA 服务登录。这部分我已经可以做,但我需要保持它。

有人对如何在 MVC 3 网站中托管 Silverlight 业务应用程序并共享身份验证有什么好主意吗?有没有办法将创建业务应用程序时生成的默认 Web 应用程序转换为 MVC 3 Web 应用程序,这可能有效吗?即使网站不能MVC,认证共享也能做到吗?

抱歉,描述过于复杂,感谢您的帮助。我真的找不到任何教程或例子,我认为这是一个共同的愿望。

I have an asp.net MVC 3 website and a silverlight 4 business application. Separately, they both use the asp membership system (the silverlight app through RIA Services). I can run them both separately and create users or login from either the website or Silverlight business app. In this respect, they also share the same database, so registering a user from either one will go to the same tables in the same database.

What I would like to do is host the Silverlight business app in the MVC 3 website and share authentication across the two. This means that the website will have a link to launch the silverlight app, so if I login through the website and launch the silverlight app, I would like the silverlight app to know I am logged in already.

Alternatively, I would like to be able to launch the silverlight app as a standalone desktop application and login through RIA Services there. This part I can do already, but I need to maintain that.

Does anyone have any good ideas of how to host a Silverlight business app in an MVC 3 website and share authentication? Is there a way to convert the default web application that generates when you create a business app into an MVC 3 web application, and might that do the trick? Even if the website can't be MVC, can the authentication sharing be done?

Sorry for the complex description, any help is appreciated. I really am at a loss to find any tutorials or examples of this, which I figured would be a common desire.

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

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

发布评论

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

评论(1

寄居者 2024-11-24 18:22:27

如果您的 Silverlight 应用程序最初是为了处理登录而开发的,那么执行此操作应该不会有问题。您可以从 ASP.NET MVC3 应用程序 (FormsAuthentication.SetAuthCookie) 进行身份验证,并拥有托管 Silverlight 应用程序的视图。当 SL 应用程序启动时,其过程的一部分是检查是否 WebContext.Current.User.IsAuthenticated,以便它将从那里接管,如果用户已经通过身份验证,您的 SL 应用程序应该绕过它的登录。

在 ASP.NET MVC3 应用程序中,您可以在托管 SL 插件的视图的控制器上粘贴 [Authorize]。除非用户经过身份验证,否则不会显示此视图。

If your Silverlight application was initially developed to handle login then you shouldn't have a problem doing this. You can authenticate from an ASP.NET MVC3 app (FormsAuthentication.SetAuthCookie) and have a view that hosts your Silverlight application. When the SL application starts up part of its process is to check if WebContext.Current.User.IsAuthenticated so it will take over from there, if the user is already authenticated your SL app should bypass it's login.

In the ASP.NET MVC3 application you can stick an [Authorize] on the controller for the view hosting the SL plugin. It won't display this view unless the user is authenticated.

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