WPF应用程序中的成员资格提供程序 [英] Membership provider in WPF application
问题描述
您好,
我有一个使用SQL Server数据库的ASP.NET Web应用程序,以确保安全:数据库已相应配置,并且一切正常.现在,我必须为一些远程操作创建一个WPF桌面应用程序,我希望它使用相同的 一个带有SqlMembershipProvider的数据库,用于验证其用户并允许他们在远程数据库中进行操作.因此,我使用相同的连接字符串和成员资格提供程序配置将app.config添加到了桌面应用程序,但是无论何时 我尝试使用任何SqlMembershipProvider方法,获取连接字符串时会得到null异常.那么,如何在桌面环境中将应用程序配置为使用相同的Web应用程序数据库?这是我的app.config:
I have an ASP.NET web application using an SQL Server database for security: the database is configured accordingly, and everything works fine in it. Now I have to create a WPF desktop application for some remote operations and I'd like it to use the same database with a SqlMembershipProvider for authenticating its users and allowing them to do their stuff in the remote database. So I added an app.config to the desktop application with the same connection string and membership provider configuration, but whenever I try to use any SqlMembershipProvider method I get a null exception when acquiring the connection string. So how should I configure the application to use the same web application database but in a desktop environment? Here is my app.config:
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=ZaxEdit;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<roleManager enabled="true"/>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="ZaxEditWeb" />
</providers>
</membership>
</system.web>
推荐答案
Naftis,
Hi Naftis,
您是否配置了客户端应用程序服务?
Have you configured Client application services?
您可以这样配置它:
1.取得项目的属性.
2.转到服务标签.
You can configure it like this:
1. Take Properties of your project.
2. Go to Services tab.
在服务"标签中,您可以对其进行配置.
In Services tab, you can configure it.
谢谢,
穆罕默德
Thanks,
Muhammad
这篇关于WPF应用程序中的成员资格提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!