在WPF应用程序中使用WebMatrix.WebData.WebSecurity [英] Using WebMatrix.WebData.WebSecurity in a WPF application
问题描述
我有一个使用开箱WebMatrix的安全性MVC4互联网项目。一个需求已经跟着一个WPF前端添加到同一个应用程序。我提出的模型到一个单独的DLL,并开始建设的WPF前端在同一实体。
I have an MVC4 internet project that uses the out of the box WebMatrix security. A requirement has come along to add a WPF front end to the same application. I have moved the model into a separate DLL and started building the WPF front end over the same entities.
我遇到的唯一问题是试图与现有的安全模型集成。我加了的System.Web部分进入我的WPF项目的app.config如下:
The only issue I am having is trying to integrate with the existing security model. I have added a system.web section into my WPF project's app.config as follows:
<system.web>
<membership defaultProvider="SimpleMembershipProvider">
<providers>
<clear/>
<add name="SimpleMembershipProvider" type="WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData" />
</providers>
</membership>
</system.web>
现在,当我打电话 WebSecurity.Login(用户名,密码)
我收到以下错误:
Now when I call WebSecurity.Login("Username", "Password")
I get the following error:
您所说的WebSecurity类的其他任何方法之前,必须调用WebSecurity.InitializeDatabaseConnection的方法。此调用应放置在一个_AppStart.cshtml文件在您的网站的根目录。
You must call the "WebSecurity.InitializeDatabaseConnection" method before you call any other method of the "WebSecurity" class. This call should be placed in an _AppStart.cshtml file in the root of your site.
我已经打过电话了 InitializeSimpleMembershipAttribute();
code自带的在我的WPF应用程序的启动时的MVC项目,但它没有什么区别到上述错误。
I have tried calling the InitializeSimpleMembershipAttribute();
code that comes with the MVC project in the start-up of my WPF application, but it makes no difference to the above error.
我找不到上线如何做到这一点,我在这里下去是死路一条的任何例子吗?
I cannot find any examples on-line of how to do this, am going down a dead end here?
任何帮助将是AP preciated。
Any help would be appreciated.
推荐答案
在最后,我决定采取不同的方法,并使用WCF身份验证服务我的不同客户之间的共享,在这个帖子的演练:使用ASP.NET应用程序服务。
In the end I decided to take a different approach and use a WCF authentication service to share between my different clients, as outlined in this post Walkthrough: Using ASP.NET Application Services.
这是不是试图让网络矩阵直接从WPF项目中工作的一个整洁的解决方案。
This was a neater solution than trying to get web matrix to work directly from inside a WPF project.
这篇关于在WPF应用程序中使用WebMatrix.WebData.WebSecurity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!