portal site Architecture

G

Guest

We are designing a site with ASP.net 2.0. The question is regarding the
options avialble in asp.net 2.0 and the best one to use

Scenario
All the pages have a top menu bar and header. (We plan to make it as a
master page). Now the menu in the master page is based on roles that a person
is assigned to (Windows AD group). What is the best option to implement this?

1. Use the default asp.net framework and get the menu based on roles (thru
sitemap). But here there will be a hit to the personalization databse
(aspnetdb) for each page. How much of a performance issue is this?

2. make the menu as a user control and cache it. Is there a way to cache the
menu based on the roles. Can VaryByParam hold multiple parameters (multiple
roles of a user)?

3. Store the menu options available to the user in the user profile . But
then can the profile be refreshed when the role of the person changes (I
believe that profiles are mainly to be used to allow the user what he/she
wants to see rather than what u want to show them based on their roles.

Suggestions? Help?
Thanks!
 
S

Scott Allen

Hi getdotnet:

We are designing a site with ASP.net 2.0. The question is regarding the
options avialble in asp.net 2.0 and the best one to use

Scenario
All the pages have a top menu bar and header. (We plan to make it as a
master page). Now the menu in the master page is based on roles that a person
is assigned to (Windows AD group). What is the best option to implement this?

1. Use the default asp.net framework and get the menu based on roles (thru
sitemap). But here there will be a hit to the personalization databse
(aspnetdb) for each page. How much of a performance issue is this?

The default SiteMapProvider (XmlSiteMapProvider) reads an XML file
(web.sitemap) and doesn't hit a database. The sitemap is read into
memory once and then cached, since there will not be much of a perf
hit there.
 
G

Guest

Thanks Scott.
Could you (or someone) please answer my other question as well

The header aslo contains user information along with teh division of teh
person. Now this information has to be capyured from a database. What is the
best way to cache this info?
Should i contain the user and division info in a user control and cache it
based on some parameter using teh outputByParam in outputcache (parameter
being the user name?)
Or is there any better way to do it?

Thanks!
 
S

Scott Allen

Personally, I'd tend to favor caching of a user control - you'll cache
not just the data but also the rendering so it's the best bang for the
buck.

It probably won't be possible to use VaryByParam, it would be a bad
idea to identify the user based on a query string param, but you could
use VaryByCustom [1]and cache based on the user's name. The example
below caches based on browser type, but you could change the code..


[1]
http://msdn.microsoft.com/library/d...pp/html/aspnet-cachingtechniquesbestpract.asp
 
G

Guest

I am now trying to cache the user control based on VaryByCustom. I have
overriden the GetVaryByCustomString in the Global .asax file

But the problem is that the Function GetVaryByCustomString is being called
only after the control has been initialized. I am doing the rendering in the
Load event of the user control. But the load event is being called much
before the GetVaryByCustomString function. So it does not pick up output from
cache.

The control is placed in a master page and the outputcache is declared like
this
<%@OutputCache Duration="1800" VaryByParam="none" VaryByCustom="UserId" %>

What am I doing wrong??



Scott Allen said:
Personally, I'd tend to favor caching of a user control - you'll cache
not just the data but also the rendering so it's the best bang for the
buck.

It probably won't be possible to use VaryByParam, it would be a bad
idea to identify the user based on a query string param, but you could
use VaryByCustom [1]and cache based on the user's name. The example
below caches based on browser type, but you could change the code..


[1]
http://msdn.microsoft.com/library/d...pp/html/aspnet-cachingtechniquesbestpract.asp

--
Scott
http://www.OdeToCode.com/blogs/scott/

Thanks Scott.
Could you (or someone) please answer my other question as well

The header aslo contains user information along with teh division of teh
person. Now this information has to be capyured from a database. What is the
best way to cache this info?
Should i contain the user and division info in a user control and cache it
based on some parameter using teh outputByParam in outputcache (parameter
being the user name?)
Or is there any better way to do it?

Thanks!
 
S

Scott Allen

What does your VaryByCustom code look like? I'll create a test here
over the weekend..

--
Scott
http://www.OdeToCode.com/blogs/scott/

I am now trying to cache the user control based on VaryByCustom. I have
overriden the GetVaryByCustomString in the Global .asax file

But the problem is that the Function GetVaryByCustomString is being called
only after the control has been initialized. I am doing the rendering in the
Load event of the user control. But the load event is being called much
before the GetVaryByCustomString function. So it does not pick up output from
cache.

The control is placed in a master page and the outputcache is declared like
this
<%@OutputCache Duration="1800" VaryByParam="none" VaryByCustom="UserId" %>

What am I doing wrong??



Scott Allen said:
Personally, I'd tend to favor caching of a user control - you'll cache
not just the data but also the rendering so it's the best bang for the
buck.

It probably won't be possible to use VaryByParam, it would be a bad
idea to identify the user based on a query string param, but you could
use VaryByCustom [1]and cache based on the user's name. The example
below caches based on browser type, but you could change the code..


[1]
http://msdn.microsoft.com/library/d...pp/html/aspnet-cachingtechniquesbestpract.asp

--
Scott
http://www.OdeToCode.com/blogs/scott/

Thanks Scott.
Could you (or someone) please answer my other question as well

The header aslo contains user information along with teh division of teh
person. Now this information has to be capyured from a database. What is the
best way to cache this info?
Should i contain the user and division info in a user control and cache it
based on some parameter using teh outputByParam in outputcache (parameter
being the user name?)
Or is there any better way to do it?

Thanks!
 
G

Guest

GetVaryByCustomString in Global.asax

Public Overrides Function GetVaryByCustomString(ByVal context As
System.Web.HttpContext, ByVal custom As String) As String
Dim userName As String

If custom = "UserId" Then 'we wish to cache this page by user id
userName = Profile.UserName
If Not userName Is String.Empty Then
Return userName
End If
End If
Return (GetVaryByCustomString(context, custom))

End Function

The user control (which i want to cache) in master page looks like this

<%@OutputCache Duration="1800" VaryByParam="none" VaryByCustom="UserId" %>
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="EmpInfo.ascx.vb"
Inherits="EmpInfo" %>
<asp:Label ID="lblWelcome" runat="server" Text="Welcome, Logout"></asp:Label>
<asp:Label ID="lblDivision" runat="server" Text="Division"></asp:Label>

I am running this in debug mode and the page-load event of the user control
fires firts. After that the GetVaryByCustomString function is initialized.

Thanks for the help

Scott Allen said:
What does your VaryByCustom code look like? I'll create a test here
over the weekend..

--
Scott
http://www.OdeToCode.com/blogs/scott/

I am now trying to cache the user control based on VaryByCustom. I have
overriden the GetVaryByCustomString in the Global .asax file

But the problem is that the Function GetVaryByCustomString is being called
only after the control has been initialized. I am doing the rendering in the
Load event of the user control. But the load event is being called much
before the GetVaryByCustomString function. So it does not pick up output from
cache.

The control is placed in a master page and the outputcache is declared like
this
<%@OutputCache Duration="1800" VaryByParam="none" VaryByCustom="UserId" %>

What am I doing wrong??



Scott Allen said:
Personally, I'd tend to favor caching of a user control - you'll cache
not just the data but also the rendering so it's the best bang for the
buck.

It probably won't be possible to use VaryByParam, it would be a bad
idea to identify the user based on a query string param, but you could
use VaryByCustom [1]and cache based on the user's name. The example
below caches based on browser type, but you could change the code..


[1]
http://msdn.microsoft.com/library/d...pp/html/aspnet-cachingtechniquesbestpract.asp

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Tue, 21 Jun 2005 12:38:13 -0700, getdotnet

Thanks Scott.
Could you (or someone) please answer my other question as well

The header aslo contains user information along with teh division of teh
person. Now this information has to be capyured from a database. What is the
best way to cache this info?
Should i contain the user and division info in a user control and cache it
based on some parameter using teh outputByParam in outputcache (parameter
being the user name?)
Or is there any better way to do it?

Thanks!
 
S

Scott Allen

Hi getdotnet:

It's working for me.

The first time I load the webform in the master page with the user
control - Page_Load fires for the user control. then GetVaryByCustom
fires to get the cache string for the control. At that point the
control is cached.

If I refresh the page just the breakpoint on GetVaryByCustom is hit -
Page_Load is not.
I am running this in debug mode and the page-load event of the user control
fires firts. After that the GetVaryByCustomString function is initialized.

You mean on the first hit? That is normal. Is it still firing
Page_Load first on the 2nd hit?
 
G

Guest

Yes. It works. Thanks for your time.

Scott Allen said:
Hi getdotnet:

It's working for me.

The first time I load the webform in the master page with the user
control - Page_Load fires for the user control. then GetVaryByCustom
fires to get the cache string for the control. At that point the
control is cached.

If I refresh the page just the breakpoint on GetVaryByCustom is hit -
Page_Load is not.


You mean on the first hit? That is normal. Is it still firing
Page_Load first on the 2nd hit?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top