Saturday, March 24, 2012

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

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
NavinYes, 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.
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
****************************************
*********
Think outside of the box!
****************************************
*********
"Navin Mishra" <navin.mishra@.siemens.com> wrote in message
news:Ojk2tqr5GHA.2208@.TK2MSFTNGP04.phx.gbl...
> 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
>
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
"Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@.comcast.netNoSpamM> wrote in
message news:%23yx0S9u5GHA.2044@.TK2MSFTNGP02.phx.gbl...
> 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.
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
> http://gregorybeamer.spaces.live.com
> ****************************************
*********
> Think outside of the box!
> ****************************************
*********
> "Navin Mishra" <navin.mishra@.siemens.com> wrote in message
> news:Ojk2tqr5GHA.2208@.TK2MSFTNGP04.phx.gbl...
>
Any sample code would really help...thanks in advance!
Navin
"Navin Mishra" <navin.mishra@.siemens.com> wrote in message
news:OGtvjBv5GHA.2044@.TK2MSFTNGP02.phx.gbl...
> 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
> "Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@.comcast.netNoSpamM> wrote in
> message news:%23yx0S9u5GHA.2044@.TK2MSFTNGP02.phx.gbl...
>
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+sBAAAAm9HBmMaT0ka0sma3lHvjeQQAAAACAAA
AAAADZgAAqAAAABAAAADICZdWipnIOoLmIKm/TFfGAAAAAASAAACgAAAAEAAAAIWa0+YCYQK2yoM
XgXduY6v4AQAABee1Y7Uz9xTwwYaZwZGk0FE+EfK
5w6O6ZjbZmAqDdOgXMk6st1S7ZRHmKRcKXIX
Iht6p7nMWkbnm1S7duVu4/sAEfG
Dy0S5OgRqr8v2cwZ8VnSe1Yxuoadw58e9+Nid1TW
Fu0amasyFKXUMJt5WhOs36a6N5mKXndYwWv8
JKewH4uhRR52aItD64/ iNYNC3fXnA0tbIA08PtPBazyFeXNlgMlQ68llwdd
mE9cizXlIYzkYkyEx
vjRhbRiYXMKenkzkFXVZH0+rXyB1JMYKXKGO9516
emzk72hz88Cl2TE064i4TnkKSu9WXSiUL705
YBdbkfW53wpuaREdobq5105np40
iWP6qWdzrULx7I46VWpUcdePfEHc/ i3GgfuAW2zNIwyKA1yGRdkrWa22iL+ymdqOP+Exb
Q0vctbH
TE4AlgmaFVNqdDRCGakMX0jB/nw3S3Q9WWlV1RAWX7Uobm0SNjb7k1E8x5DRgQG/74WGcucGRVXv
GU//D+7fu776CW0crdoFC5q3tmLo7EoOFKQNkDkfqk/C7Wklh/2oBVzvTQR9Jhp0M5XUDMXmtGkw
AhsDOj/RgkqEKj5bTHb5CRrY91d
QQSYEFgJgbvuOyWYT+N2qsPldQxWOjK0GGyb8jk/mxq6i9tKBp2jKWtVaLIayfejIxY76Au6FAAA
ABq6ejD10wN+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>
"Cowboy (Gregory A. Beamer)" wrote:

> 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 ma
in
> difference is you generally do not want to hold session in web services li
ke
> you might in a web application.
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
> http://gregorybeamer.spaces.live.com
> ****************************************
*********
> Think outside of the box!
> ****************************************
*********
> "Navin Mishra" <navin.mishra@.siemens.com> wrote in message
> news:Ojk2tqr5GHA.2208@.TK2MSFTNGP04.phx.gbl...
>
>

0 comments:

Post a Comment