By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,688 Members | 1,845 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,688 IT Pros & Developers. It's quick & easy.

Using Web application with Profile

P: n/a
Hi there,

I would like to open my Asp.Net project as a "Web Application" rather than
as a "Web Site" in Visual Studio.
But the thing is that I use the System.Web.Profile and the auto-generated
class "ProfileCommon myApp.Profile", which provides me with type profile
properties. And the fact is that this generated class is not generated with
Web app...

For ex, in the web site project, if "X" is a profile Property, I can write:
using System.Web.Profile;
....
Profile.X = "nnnn";

However I could use some code like this in the web application project:
Membership.ApplicationName = "myApp";
ProfileBase userpf = ProfileBase.Create(userName); // the current
user name
// Value ot the "X" profile property
string valeur = userpf.GetPropertyValue("X").ToString();

The thing is that I don't have the current user name, although I could save
in a hidden field for instance after the user has logged in the login page
(this is of course a form authentication app).

In that case, will it work ?

Is there anything more straightforward to convert my VStudio web site
project in a VStudio web app project ?

Regards

Aug 26 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Oriane,

As for using Profile in Web Application Project, the dev team do have
noticed this issue and have produced some add-on component for generating a
helper Profile class in WEb application project, you can have a look at the
"Web Profile Builder":

#Web Profile Builder
http://code.msdn.microsoft.com/WebProfileBuilder

#Web Profile Builder for Web Application Projects
http://weblogs.asp.net/joewrobel/arc...e-builder-for-
web-application-projects.aspx
In addition, the method you used(manually use HttpContext.Profile class to
manipulate profile) is also a good approach. And for the "Username" issue
you mentioned, I think you can use the following method to get the current
username(for the profile):

=====================
protected void Page_Load(object sender, EventArgs e)
{

Response.Write("<br/>current profile username: " +
Context.Profile.UserName);
}
==================

this works even for anonymous user(will give you the auto-generated guid
for the anonymous user).

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: "Oriane" <or****@noemail.noemail>
Subject: Using Web application with Profile
Date: Tue, 26 Aug 2008 18:56:28 +0200
>Hi there,

I would like to open my Asp.Net project as a "Web Application" rather than
as a "Web Site" in Visual Studio.
But the thing is that I use the System.Web.Profile and the auto-generated
class "ProfileCommon myApp.Profile", which provides me with type profile
properties. And the fact is that this generated class is not generated
with
>Web app...

For ex, in the web site project, if "X" is a profile Property, I can write:
using System.Web.Profile;
...
Profile.X = "nnnn";

However I could use some code like this in the web application project:
Membership.ApplicationName = "myApp";
ProfileBase userpf = ProfileBase.Create(userName); // the current
user name
// Value ot the "X" profile property
string valeur = userpf.GetPropertyValue("X").ToString();

The thing is that I don't have the current user name, although I could
save
>in a hidden field for instance after the user has logged in the login page
(this is of course a form authentication app).

In that case, will it work ?

Is there anything more straightforward to convert my VStudio web site
project in a VStudio web app project ?

Regards

Aug 27 '08 #2

P: n/a
Hi Steven,
"Steven Cheng [MSFT]" <st*****@online.microsoft.coma écrit dans le message
de news:$H*************@TK2MSFTNGHUB02.phx.gbl...
Hi Oriane,

As for using Profile in Web Application Project, the dev team do have
noticed this issue and have produced some add-on component for generating
a
helper Profile class in WEb application project, you can have a look at
the
"Web Profile Builder":

#Web Profile Builder
http://code.msdn.microsoft.com/WebProfileBuilder

#Web Profile Builder for Web Application Projects
http://weblogs.asp.net/joewrobel/arc...e-builder-for-
web-application-projects.aspx
Thanks for your answer. However, I had a glimpse on this page:
http://weblogs.asp.net/jgalloway/arc...ile-class.aspx,
and I find this solution convenient to me.

Best regards

Aug 27 '08 #3

P: n/a
Hi Oriane,

Thanks for your followup. I'm glad that you've also found the solution and
share this with us.

Have a good day!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Oriane" <or****@noemail.noemail>
References: <OI**************@TK2MSFTNGP03.phx.gbl>
<$H*************@TK2MSFTNGHUB02.phx.gbl>
>In-Reply-To: <$H*************@TK2MSFTNGHUB02.phx.gbl>
Subject: Re: Using Web application with Profile
Date: Wed, 27 Aug 2008 13:54:37 +0200
>
Hi Steven,
"Steven Cheng [MSFT]" <st*****@online.microsoft.coma écrit dans le
message
>de news:$H*************@TK2MSFTNGHUB02.phx.gbl...
>Hi Oriane,

As for using Profile in Web Application Project, the dev team do have
noticed this issue and have produced some add-on component for
generating
>a
helper Profile class in WEb application project, you can have a look at
the
"Web Profile Builder":

#Web Profile Builder
http://code.msdn.microsoft.com/WebProfileBuilder

#Web Profile Builder for Web Application Projects
http://weblogs.asp.net/joewrobel/arc...e-builder-for-
>web-application-projects.aspx
Thanks for your answer. However, I had a glimpse on this page:
http://weblogs.asp.net/jgalloway/arc...-custom-asp-ne
t-profile-class.aspx,
>and I find this solution convenient to me.

Best regards

Aug 28 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.