我正在工作的WCF服务,需要会员和配置文件访问。
我通过使用System.Web.Security.Membership类并调用CreateUser()和ValidateUser()让会员工作,但是我不能让这个配置文件工作。我甚至不知道该调用哪个类,我看到的所有示例都是针对ASP.net的,就像我在下面发布的示例一样。
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
txtFirstName.Text = Profile.FirstName;
txtLastName.Text = Profile.LastName;
int foo = Profile.Age;
}
}当我在我的WCF端点中尝试这样做时,配置文件对象不可用,并且我找不到任何其他方法来访问它。
有人能告诉我如何访问个人资料的详细信息的编写方向吗?
发布于 2009-06-27 08:43:46
我认为这个问题涵盖了你的问题:
Why was the Profile provider not built into Web Apps?
我会尝试使用其中一个答案中提到的Web Profiler Builder -似乎可以帮助您。另一种方法是以类似于自动生成的方式对配置文件周围的强类型包装器进行手工编码。
发布于 2009-06-27 00:35:18
您是否为您的WCF服务启用了asp.net兼容性?您是否使用IIS托管WCF服务,而不是windows服务?
为了使用该行为,您需要执行上述两项操作。
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class MyService : IMyService
{
}发布于 2020-06-29 12:01:53
将此代码添加到web.config文件中
<system.web>
<profile enabled="true">
<properties>
<add name="Name"/>
<add name="Gender"/>
<add name="MobileNo"/>
<add name="Address"/>
</properties>
</profile>
</system.web>default.aspx.cs文件
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
txtFirstName.Text = Profile.Name;
txtGender.Text = Profile.Gender;
txtMobile.Text=Profile.MobileNo;
textAddress=Profile.Address;
}
}https://stackoverflow.com/questions/1051819
复制相似问题