In what "event" should i put the -account-ID-session code?
I am currently building a new site, where my customers get their own subdomain. for example:
user1.mydomain.com
user2.mydomain.com
userDef.mydomain.com
...
The site is built in and running on: IIS, asp.net C#
So. Because there is a lot of virtual host subdomains. i have a Function in my code that connects to the database and check the ID of the account.
SELECT account_ID where account_subdomain = 'user##开发者_运维问答' LIMIT 1;
Depending on the ID both masterpage AND contentpage return different data / design.
My question is, in which "event" should i put my function that put the accountID in the session("accountID")?
because i want this on every single page i tried to put it in page_load in masterpage, but this is too late. I guess that page_load in content page is rendered before the page_load in masterpage?
Soo, is there any good place to put my function so the account ID checkup is done before anything else is written on the webpage?
Thanks! Matte
One option is to create an HttpModule and put your code in there, since it would get to the page requests before the actual page starts processing. That would ensure that your account id was available on every page and set before any of the events you would need it in.
If you do end up going this route, you would need to put your code in the PostAcquireRequestState or PreRequestHandlerExecute events so that Session will be available for you to modify.
Try putting the code in Page_Init event of your master page. Page_Load event of content page is called before the Page_Load event of the master page. However, in case of Page_Init this is in reverse.
精彩评论