Web Profile Builder for Web Application Projects - Joe Wrobel

 

Web Profile Builder for Web Application Projects

Files can be downloaded from the Web Profile Builder project page.

If you use Web Application Projects, you have probably run into the issue of not being
able to access the Profile at design time.

Usage:

  1. Run the installer.
  2. Add this Import statement to your project file.  (see special notes below)
    <Import Project=”$(MSBuildExtensionsPath)\WebProfileBuilder\WebProfileBuilder.targets” />
  3. Load Project  (if the project failed to load…make sure the you fixed the “” on step2)
  4. After you modify the project file by adding the import statement, you will get this security
    warning when the project loads.  Choose the “Load project normally” option and press OK
  5. Add a WebProfile.cs file in the root directory.
  6. Build the Project. The profile will get generated every time you made changes to the Profile - Properties in the web.config. 

Optional: Add the section group if you need to customize the namespace, classname and the output file path.

Usage:

1. Add a static Property to wrap around the WebProfile class: e.g. for current user

public static WebProfile Profile
{
    get { return new WebProfile(HttpContext.Current.Profile); }
}

2. Set: e.g. Profile.Counter++

3. Get: e.g. Profile.Counter,

e.g. For particular user

var user = new WebProfile().GetProfile(”User”);

           user.City = “New city”;

           user.Save();

Web Profile Builder for Web Application Projects - Joe Wrobel