You could just pass the url as a query string parameter to the page in the subsite. Wouldn't something like this work? http://myportal/mysite/mysubsite/default.aspx?refurl=http://myportal/mysite
In your code on the subsite page, you can read the querystring and create your site object using that. The query strings should be retained on postback.
UPDATE: Maybe I misunderstood the problem. As I understand it now, you are trying to get the url of the subsite in which the url resides... Try the following:
using (SPSite siteCollection = new SPSite("http://MyServer/MySite/MySubSite/MyDocLib/Page.aspx"))
{
SPWeb myWeb = siteCollection.OpenWeb();
string weburl = myWeb.Url;
}