Newbie: using asp.net 2.0 profile in an ASP.NET web service

N

Navin Mishra

Hi,

Is it possible to use asp.net 2.0 profile in an ASP.NET web service ? I
want to authenticate a user via the web service and store user profile data
using ASP.NET 2.0 profile ? Is it possible at all ?

Thanks in advance and regards

Navin
 
C

Cowboy \(Gregory A. Beamer\)

Yes, it is possible. You hook the app up to the profile provider and then
add info from the service using the membership and/or profile bits. The main
difference is you generally do not want to hold session in web services like
you might in a web application.
 
N

Navin Mishra

Some sample code would help. In a web service, the profile keys added don't
appear as properties of Profile object but in an ASP.NET web app they do.

Thanks in advance and regards

Navin
 
G

Guest

I am having a problem with this as well
What I am trying to do is to have a textbox that a user begins to type what
he is searching for.
I am using an AutoCompleteExtender to call a method in the web service that
queries the database for the field description and pull "like" results.
The problem is that I already have a profile that handles the users profile,
but I need to add another profile for the property dragOverlayPosition.
Here is my web.config: (sorry its long)

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<!--
The configSections define a section for ASP.NET Atlas.
-->
<configSections>
<sectionGroup name="microsoft.web"
type="Microsoft.Web.Configuration.MicrosoftWebSectionGroup">
<section name="converters"
type="Microsoft.Web.Configuration.ConvertersSection"
requirePermission="false"/>
<section name="webServices"
type="Microsoft.Web.Configuration.WebServicesSection"
requirePermission="false"/>
<section name="authenticationService"
type="Microsoft.Web.Configuration.AuthenticationServiceSection"
requirePermission="false"/>
<section name="profileService"
type="Microsoft.Web.Configuration.ProfileServiceSection"
requirePermission="false"/>
</sectionGroup>
</configSections>
<!--
The microsoft.web section defines items required for the Atlas
framework.
-->
<microsoft.web>
<converters>
<add
type="Microsoft.Web.Script.Serialization.Converters.DataSetConverter"/>
<add
type="Microsoft.Web.Script.Serialization.Converters.DataRowConverter"/>
<add
type="Microsoft.Web.Script.Serialization.Converters.DataTableConverter"/>
</converters>
<webServices enableBrowserAccess="true"/>
<authenticationService enabled="true"/>
<!-- The example application needs the profileService to be enabled and to
specify the dragOverlayPosition property. -->
<profileService enabled="true" setProperties="dragOverlayPosition"
getProperties="dragOverlayPosition"/>
</microsoft.web>
<appSettings>
<add key="Online" value="1"/>
<add key="ReBidLimit" value="20"/>
</appSettings>
<connectionStrings
configProtectionProvider="DataProtectionConfigurationProvider">
<EncryptedData>
<CipherData>

<CipherValue>AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAm9HBmMaT0ka0sma3lHvjeQQAAAACAAAAAAADZgAAqAAAABAAAADICZdWipnIOoLmIKm/TFfGAAAAAASAAACgAAAAEAAAAIWa0+YCYQK2yoMXgXduY6v4AQAABee1Y7Uz9xTwwYaZwZGk0FE+EfK5w6O6ZjbZmAqDdOgXMk6st1S7ZRHmKRcKXIXIht6p7nMWkbnm1S7duVu4/sAEfGDy0S5OgRqr8v2cwZ8VnSe1Yxuoadw58e9+Nid1TWFu0amasyFKXUMJt5WhOs36a6N5mKXndYwWv8JKewH4uhRR52aItD64/iNYNC3fXnA0tbIA08PtPBazyFeXNlgMlQ68llwddmE9cizXlIYzkYkyExvjRhbRiYXMKenkzkFXVZH0+rXyB1JMYKXKGO9516emzk72hz88Cl2TE064i4TnkKSu9WXSiUL705YBdbkfW53wpuaREdobq5105np40iWP6qWdzrULx7I46VWpUcdePfEHc/i3GgfuAW2zNIwyKA1yGRdkrWa22iL+ymdqOP+ExbQ0vctbHTE4AlgmaFVNqdDRCGakMX0jB/nw3S3Q9WWlV1RAWX7Uobm0SNjb7k1E8x5DRgQG/74WGcucGRVXvGU//D+7fu776CW0crdoFC5q3tmLo7EoOFKQNkDkfqk/C7Wklh/2oBVzvTQR9Jhp0M5XUDMXmtGkwAhsDOj/RgkqEKj5bTHb5CRrY91dQQSYEFgJgbvuOyWYT+N2qsPldQxWOjK0GGyb8jk/mxq6i9tKBp2jKWtVaLIayfejIxY76Au6FAAAABq6ejD10wN+VUxBxgESIh2z4oQ+</CipherValue>
</CipherData>
</EncryptedData>
</connectionStrings>
<system.web>
<httpHandlers>
<add path="Reserved.ReportViewerWebControl.axd" verb="*"
type="Microsoft.Reporting.WebForms.HttpHandler,
Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" validate="false"/>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx"
type="Microsoft.Web.Services.ScriptHandlerFactory" validate="false"/>
<add verb="*" path="*.asbx"
type="Microsoft.Web.Services.ScriptHandlerFactory" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="Microsoft.Web.Services.ScriptModule"/>
<add name="BridgeModule" type="Microsoft.Web.Services.BridgeModule"/>
<add name="WebResourceCompression"
type="Microsoft.Web.Services.WebResourceCompressionModule"/>
</httpModules>
<customErrors mode="RemoteOnly" defaultRedirect="~/Controls/Error.aspx"/>
<roleManager enabled="true" cacheRolesInCookie="true"
cookieName="gsauctionrole" defaultProvider="GSARoleProvider">
<providers>
<add connectionStringName="gsauctionsConnectionString"
applicationName="/" name="GSARoleProvider"
type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</roleManager>
<siteMap defaultProvider="GSASiteMapProvider" enabled="true">
<providers>
<add name="GSASiteMapProvider" type="System.Web.XmlSiteMapProvider"
securityTrimmingEnabled="true" siteMapFile="Web.sitemap"/>
</providers>
</siteMap>
<anonymousIdentification cookieless="AutoDetect" enabled="true"/>
<profile defaultProvider="GSA_ProfileProvider" enabled="True">
<providers>
<add name="GSA_ProfileProvider"
type="Microsoft.Samples.SqlTableProfileProvider"
connectionStringName="gsauctionsConnectionString" table="gsa_Profiles"
applicationName="/"/>
</providers>
<!-- Old Way
<providers>
<add name="GSA_ProfileProvider"
connectionStringName="gsauctionsConnectionString"
applicationName="/"
type="System.Web.Profile.SqlProfileProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
-->
<properties>
<add name="Email" type="String" defaultValue="[null]"
customProviderData="Email;nvarchar"/>
<add name="UserName" type="String" defaultValue="[null]"
customProviderData="UserName;nvarchar"/>
<add name="FirstName" type="String" defaultValue="[null]"
customProviderData="FirstName;nvarchar"/>
<add name="LastName" type="String" defaultValue="[null]"
customProviderData="LastName;nvarchar"/>
<add name="Organ" type="String" defaultValue="[null]"
customProviderData="Organ;nvarchar"/>
<add name="Dept" type="String" defaultValue="[null]"
customProviderData="Dept;nvarchar"/>
<add name="JobTitle" type="String" defaultValue="[null]"
customProviderData="JobTitle;nvarchar"/>
<add name="TaxEmp" type="String" defaultValue="[null]"
customProviderData="TaxEmp;nvarchar"/>
<add name="NonPro" type="String" defaultValue="[null]"
customProviderData="NonPro;nvarchar"/>
<add name="Street1" type="String" defaultValue="[null]"
customProviderData="Street1;nvarchar"/>
<add name="Street2" type="String" defaultValue="[null]"
customProviderData="Street2;nvarchar"/>
<add name="PostalCode" type="String" defaultValue="[null]"
customProviderData="PostalCode;nvarchar"/>
<add name="City" type="String" defaultValue="[null]"
customProviderData="City;nvarchar"/>
<add name="State" type="String" defaultValue="[null]"
customProviderData="State;nvarchar"/>
<add name="Country" type="String" defaultValue="[null]"
customProviderData="Country;nvarchar"/>
<add name="TPh1" type="String" defaultValue="[null]"
customProviderData="TPh1;nvarchar"/>
<add name="TPh2" type="String" defaultValue="[null]"
customProviderData="TPh2;nvarchar"/>
<add name="CPh1" type="String" defaultValue="[null]"
customProviderData="CPh1;nvarchar"/>
<add name="CPh2" type="String" defaultValue="[null]"
customProviderData="CPh2;nvarchar"/>
<add name="Fax1" type="String" defaultValue="[null]"
customProviderData="Fax1;nvarchar"/>
<add name="Fax2" type="String" defaultValue="[null]"
customProviderData="Fax2;nvarchar"/>
</properties>
</profile>
<!-- Hide those ugly URLs -->
<urlMappings>
<add url="~/Default.aspx?pg=admin" mappedUrl="~/Admin/Default.aspx"/>
<add url="~/Default.aspx?pg=musr" mappedUrl="~/Admin/ManageUsers.aspx"/>
<add url="~/Default.aspx?pg=mcat" mappedUrl="~/Admin/ManageAssets.aspx"/>
<add url="~/Default.aspx?pg=mbid" mappedUrl="~/Admin/ManageAuctions.aspx"/>
<add url="~/Default.aspx?pg=fpwd" mappedUrl="~/Users/Forgotpwd.aspx"/>
<add url="~/Default.aspx?pg=login" mappedUrl="~/Users/Login.aspx"/>
<add url="~/Default.aspx?pg=mpro" mappedUrl="~/Users/MyProfile.aspx"/>
<add url="~/Default.aspx?pg=reset" mappedUrl="~/Users/ResetPwd.aspx"/>
<add url="~/Default.aspx?pg=reg" mappedUrl="~/Users/Register.aspx"/>
</urlMappings>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.

Visual Basic options:
Set strict="true" to disallow all data type conversions
where data loss can occur.
Set explicit="true" to force declaration of all variables.
-->
<compilation debug="true" strict="false" explicit="true">
<assemblies>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=B77A5C561934E089"/></assemblies>
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider,
Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"/>
<add extension=".asbx" type="Microsoft.Web.Services.BridgeBuildProvider"/>
</buildProviders>
<codeSubDirectories>
<add directoryName="CSCode"/>
<add directoryName="VBCode"/>
</codeSubDirectories>
</compilation>
<pages theme="GSAuction" masterPageFile="~/GSAuction.master">
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
<add namespace="System.Net.Mail"/>
</namespaces>
</pages>
<!--
<authorization>
<allow users="*" />
</authorization>

The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Forms">
<forms loginUrl="Default.aspx"></forms>
</authentication>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
-->
<membership defaultProvider="GSAMembershipProvider"
userIsOnlineTimeWindow="15">
<providers>
<add name="GSAMembershipProvider"
connectionStringName="gsauctionsConnectionString" applicationName="/"
requiresUniqueEmail="false" minRequiredPasswordLength="7"
minRequiredNonalphanumericCharacters="0"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</membership>
</system.web>

How or where do I stick this?

<!-- The SimpleList application needs profile to be enabled, and to allow
anonymous users access to the property. -->
<profile enabled="true">
<properties>
<add allowAnonymous="true" name="dragOverlayPosition" defaultValue=""
serializeAs="String"/>
</properties>
</profile>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top