views:

278

answers:

2

Hi there

I have a base page (inherited from System.Web.UI.Page and all my pages inherit from this base page) in my .Net web application and at the moment if I put the following methods:

protected int GetProfileTenant()
    {
        try
        {
            ProfileCommon p = Profile.GetProfile(Profile.UserName);
            return Convert.ToInt32(p.TenantID);
        }
        catch
        {
            return -1;
        }
    }

the error come up saying that "the Name Profile does not existin the current context".

This methods if I put this into the page (inherited from the base page clas) works well (no issue).

Any ideas?

Thanks

Thanks

A: 

I don't have a clear-cut answer for you, but there is some "magic" happening in the way profiles work (a class matching your profile properties gets generated). Apparently the Profile property gets injected into the top level page class. Have you tried using HttpContext.Current.Profile instead?

Thorarin
A: 

Add System.web namespace in the class. and try this

HttpContext.Current.Profile.UserName
Muhammad Akhtar