So a couple of comments....
First, this really has nothing to do with the global.asax and the code you're looking at in Application_BeginRequest is what's used either on initial installation or when performing an upgrade. This is done at the codebase level and would affect all of your portals.
Next, the logic to determine what portal you are viewing is a pretty low level function. You'll have to really dig through a lot of code in the admin/portal and admin/tabs folders as well as default.aspx.vb. The default file really starts everything. You should also look at how the portals/[portalid]/default.aspx page does its settings and redirects to the root default page. By examining the portals, portalalias, and tabs tables in the database, you can get an idea of how things are separated.
Lastly, your first post said you are relatively new to .net and a subsequent post said you are trying to build a portal application. I guess my follow up question would be Why? DNN does all of this and is an outstanding portal framework. That's why we're all here. It's one thing to want to understand what's going on; it's another to try and recreate the wheel. If you do it all from scratch, once you get the multi-portals concept licked, you'll have to start in on stuff like How do skins work?, How do I build a membership provider?, and What's the best way to implement your own client api?. This list goes on and on...
I guess my point is unless you're goal is to develop an application framework to compete against DNN, why not just use DNN? Every large business, consulting firm and seasoned developer uses some kind of framework as their basis for all projects (and no the .NET Framework doesn't count -- it's just too big to use as a starting point). You don't want to have to do all the plumbing each time you start a project; you want to start with a framework that sits on top of .NET that you trust has handled all the grunt work so you can concentrate on your business logic. This applies to Java as well. Every Java developer I know uses a framework they trust as a starting point for most applications.
I may be misunderstanding what you're trying to do, but it sounds like you're trying to redevelop a lot of code and features unnessicarily... especially if you're new to .net development. If I were your supervisor or a paying client, I'd be pretty upset if you hit me with a bill for 100s (or 1000s) of hours developing your own framework when you could get a proven, stable one for free.
Don't take me wrong. I'm not slamming you personally. You obviously see that DNN has some cool features and recognize it's value. If you didn't you wouldn't be here in the first place. I just think you should consider using DNN as your framework and spend your precious coding hours on custom modules and your company's/customer's business needs.