Wednesday, March 28, 2012

ProfileScriptService Question

Can someone tell me where the physical location of the ProfileScriptService setting ar location. Are they stored in a cookie?

The settings are stored into Profile - which is the standard ASP.NET 2.0 profile feature.

The profile feature allows you to define the specific storage mechanism and store to use and customize via configuration in your web.config file using a provider model. Check out the docs on profile for more info...

ProfileScriptService not sticking

Is there something I'm missing. I get the drag and drop to work but I cannot get the profile setting to save. It resets the setting on a postback.

Did you try to use Fiddler or Nikhil's browser helper to monitor the exchanges with the profile service and see if there's an error message there?

ProfileScriptService Explanation

Hi,

I'm trying to understand and know all new controls Atlas has. By now, I made some examples with AutoCompleteExtender and DragOverlayExtender and all work well.

But, 'm trying to do something with ProfileScriptService and I don't know how it works. I searched information in google, in some blogs for Atlas and found one post in asp.net forum telling about other control in which there is a ProfileScripService control declared. I tested this example but I can't understand the functionality of this control.

Can someone tell me something about ProfileScriptService??

Thanks.

I am in the same boat, I am trying to get the profile script service samples from the presentations on the web to work, but they just don't work. TTYL.

hello.

well, it's just a custom proxy which wraps calls made over a web service defined in the atlas dll. so, what can you do with it? well you can get or save the properties of your profile that have been atlas enabled. to enable a property to be used, you must add it explicitly to the profileService element in the web.config file.

then, on the client side, you get the profile info by calling the load method (btw, you should also add a handler to the loaded event so that you'll be notified when the properties are loaded). to save eventual property changes, you have 2 options: autosave (in this case, you don't have to do anything) or the manual save( calling the save method).

to explain all these aspects, here's a simple example. suppose your asp.net profile has these properties:

<profile enabled="true">
<properties>
<add name="Nome" type="System.String" />
<group name="Morada">
<add name="Rua" type="System.String"/>
<add name="Porta" type="System.String"/>
</group>
</properties>
</profile>

and you want to access all of them on the client side. so, you must also add these lines to activate the atlas profile service:

<profileService
enabled="true"
setProperties="Nome; Morada.Rua;Morada.Porta"
getProperties="Nome; Morada.Rua;Morada.Porta" />

and now, you can build a simple page to get them and change them. here's some simple html that defines the page structure:

<atlas:ScriptManager runat="server" ID="manager" />

<span>Primeiro nome:</span><input type="text" id="nome" />
<br />
<span>Rua:</span><input type="text" id="rua" />
<br />
<span>Porta:</span><input type="text" id="porta" />
<p></p>
<input type="button" id="modificar" value="Actualizar perfil" onclick="actualiza()" disabled="disabled" />

and here's the jscript that might be used with it:

Sys.Application.load.add( onload );
function onload( sender, eventArgs )
{
Sys.Profile.set_autoSave( false );
Sys.Profile.loaded.add( onProfileLoaded );
Sys.Profile.saved.add( onProfileSaved );
Sys.Profile.load();
}

the profile properties are loaded after the page has loaded everything. i've also disabled autosave and set 2 handlers for the loaded and saved events. During the loaded event, i fill the controls; during the saved event, i show an alert which says that everything has been sa

function onProfileLoaded( sender, eventArgs )
{
$("nome").value = Sys.Profile.properties.Nome;
$("rua").value = Sys.Profile.properties["Morada.Rua"];
$("porta").value = Sys.Profile.properties["Morada.Porta"];

$("modificar").disabled = false;
}

function onProfileSaved( sender, eventArgs )
{
alert( "Dados perfil guardados");
}

function actualiza()
{
Sys.Profile.properties["Nome"] = $("nome").value;
Sys.Profile.properties["Morada.Rua"] = $("rua").value;
Sys.Profile.properties["Morada.Porta"] = $("porta").value;

Sys.Profile.save();
}

btw, some important observations:

* the property group sintax must use the [ ] operator
* though you can use this service from xml-script, there's currently several limitations when you have proeprties and subproperties
* pay attention if you use datetime values

Profilewebserice path doesnt work under virtual url.

I tried to find a way to replace profilewebservice with my own webservice or class, and then I found a problem. I don;t believe it is happening, but I am not sure what is wrong.

In ATLAS.js, we can find code like

Sys._Profile.WebServicePath = 'ScriptServices/Microsoft/Web/Services/Standard/ProfileWebService.asmx';

see the webservicepath is relative. When I go tohttp://mydomain.com/page/home.aspx, and do Sys.Profile.Load, I get this error:

Parser Error Message:The directive 'Page' is unknown.

Source Error:

Line 1: <%@dotnet.itags.org. Page Language="C#" ValidateRequest="false" ViewStateEncryptionMode="Never" Debug="false" EnableEventValidation="false"Line 2: CompilationMode="Never" Inherits="LinkLibrary.LinkPage" %>


Source File:/page/ScriptServices/Microsoft/Web/Services/Standard/ProfileWebService.asmx Line:1

looks like it add my virtualpath in, that doesn't sound right?

Well, it looks like your web service .asmx file has an @.Page directive in it... no? Which is wrong, if true. That's how it appears to me from what you've posted, anyway.

the asmx is ATLAS asmx.

It shows where the error happens, the @.Page is in my page.


? you said you replaced the prepackaged asmx with your own in your first post. Maybe if you posted your code, it'd be easier to help you debug it?

Oh, that confused you.

What I tried to say is I tried to find a way to use my asmx, but before I found a solution, I found a bug .

What I put on my page is just like this :

Sys.Profile.set_autoSave(false);
Sys.Profile.loaded.add(onProfileLoadComplete);
Sys.Profile.load();

and I got that error, because the test url ishttp://mydomain/page/home.aspx.

It seems the webservice add the page into its webservicepath.

If this is really a bug, I think ATLAS group should fix it. I am not sure why others didn't find it.

Line 1: <%@. Page Language="C#" ValidateRequest="false" ViewStateEncryptionMode="Never" Debug="false" EnableEventValidation="false"Line 2: CompilationMode="Never" Inherits="LinkLibrary.LinkPage" %>


Source File:/page/ScriptServices/Microsoft/Web/Services/Standard/ProfileWebService.asmx Line:1

You can tell from the error message, "ScriptServices/Microsoft/Web/Services/Standard/ProfileWebService.asmx " is what ATLAS defined in its js, but the path doesn't have "/" in front of it, I think that is where the problem from.



Have you tried giving it an absolute url just to test it and see if it's not getting hung up on where to start?


Yes, now I am using my own asmx, I set it with absolute path, it works fine under that url - /page/home.aspx
Glad to hear it!

profileService with anything other than SQL

Let's say there is no SQL Server or SQL Express on the Web Server. How would one go about implementing the whole profile thing? You can supposedly use another source for a provider? Like an XML file or something like that. Has anyone sucessfully done this, or am I the only idiot trying this? I've been scowering Google for a few hours now and I'm no further along than I was 3 hours ago.

Profiles are part of the membership provider in the .net framework. What you need to do is write a custom membership provider.

Here's a good article on what your looking for

http://www.devx.com/asp/Article/29256

Here's my google search term

http://www.google.com/search?hl=en&q=Custom+Membership+Provider+%2B+ASP.net+2.0+%2B+XML


Thanks, but I've decided to go in another direction. I'm going to use cookies instead. They're just easier to use.

As advice, cookies are a dated way to handle things likes that, and you probably should look into newer methods.

What happens, if a user has created a profile, with information about theselves, or the way they like to use your website, and then they log on from a different computer...or clear their cookies?

I understand having to remember all my passwords for every site I visit, after I clear my cookies, but if that website lost all my settings, and personal / profile information just because I cleared my cookies, I'd be pissed.


Well then I would be forced to direct them top a web page picturing a straw, and suggest they suck it up. Mind you I'm not telling you to do that, I'm just suggesting one course of action with comedic twist.

Thanks for your input anyway.

profileservice newbie question

Do the callbacks return before the Sys.Services.ProfileService.save() returns ?

Sys.Services.ProfileService.save(['myProperty'], onSaveCompleted, onProfileServiceFailed,null);

In otherwords, when Sys.Services.ProfileService.save() returns, can I assume the property is saved (barring no error occured)? or do I specifically need to wait for onSaveCompleted()

Since this is an asynchronous call, Sys.Services.ProfileService.save() will return immediatelybefore the save code on the server gets executed.

So you cannot assume that the property is saved before onSaveCompleted() is fired
because there could be errors on the server during processing in which case onProfileServiceFailed() will be fired.


Thanks! That is what I suspected but wanted confirmation.

ProfileService authentication

I use a asp.net loginbox and forms authentication (in a modalopopup) and once the user is authenticated I store the user name in a session variable.Now in a page I have to load the users profile and I am using ProfileServices.Load().I follow all the steps according to the documentation but no profile information loads on the page.

1. Is that I need to authenticate the user using Sys.Services.Authentication to use ProfileServices?

2. If I use Sys.Services.Authentication and Sys.ProfileServices then how will I store the username in a session variable if I need so?

Please help me...I am trying to explore this for the past few weeks......

Hi,

By default, no profile properties are available. For each profile property that you want to make available in a client application, add the property name to thereadAccessProperties attribute of the<profileService> element. Similarly, for each server profile property that can be set based on data sent from a client application, add the property name to thewriteAccessProperties attribute. The following example shows how to expose individual properties.

<profileService enabled="true"
readAccessProperties="Backgroundcolor,Foregroundcolor"
writeAccessProperties=" Backgroundcolor,Foregroundcolor"/>

Have you exposed individual properties?

Did the sample work on your machine?

You don't have to use Sys.Service.Authentication to use the ajax Profile service.

I don't think you read the documentation carefully as the sample is use the ajax Profile service independent.

If you have further question,please provide your code.

Best Regards,