Force root, kill virtual AppPath please

Sep 2, 2007 at 4:11 AM
How can I force to ignore any relative virtual application path?

Currently, the application path is /App1 or even /Domains/Site1
BE.NET resolves the absolute URI to http://www.MyDomain.com/App1/default.aspx

Please help me to force ALL requests (/post.aspx /syndication.axd /category/general.aspx, etc) displayed without that App1 subfolder.

Thank you so much,
MikevZ
Sep 2, 2007 at 10:25 AM
If you install BE in the root, that's what happens - I'm running it at http://blogsformoney.com/ in the root without any problems. If you put it inside a folder (virtual or otherwise) like "App1", all paths will point in there, since it can't rewrite requests from a higher level folder.
Coordinator
Sep 2, 2007 at 12:21 PM
You can manually change it in the Utils class by modifying the RelativeWebRoot and AbsoluteWebRoot properties
Sep 2, 2007 at 1:17 PM
Forgive my lack of C# knowledge, but could you please give a code snippet of what actually to change in Utils.cs before building the .dll? Thanks!

(cause everything I tried myself so far wasn't actually working, either nuking the CSS, only updating posts URIs and not trackback/admin sections, etc)
Coordinator
Sep 2, 2007 at 1:30 PM
Change only the RelativeWebRoot from:

public static string RelativeWebRoot
{
get { return VirtualPathUtility.ToAbsolute("~/"); }
}

To:

public static string RelativeWebRoot
{
get { return VirtualPathUtility.ToAbsolute("/"); }
}
Sep 2, 2007 at 1:42 PM
Danny, this all has to do with how the hoster has setup their configuration. There is nothing else I can do than use a subfolder in the "/" root for every -other- domain I like to host and set up which automatically sets up as a seperate application. I.e., the "/" root already contains ASP.NET code for the primary domain e.g. (www.CorporateDomain.com). Whenever I add a new domain (e.g., www.BlogForPartner.com), it simply has to reside in a subfolder which the website is pointing to (e.g. /MoreDomains/BFP-com).

The engine does run on www.BFP.com, but whenever I click a post, feed, etc BE.NET automatically turns that into www.BFP.com/sites/BFP-com/post/hi-there.aspx. It's just how the URI is constructed by the .dll and presented to the reader. Manually changing that URL in the browser to www.BFO.com/post/hi-there.aspx works too, but I cannot force BE.NET yet to only generate those kind of full, URIs.

Like Mads says, there must be a way to modify the Utils class but I simply don't know with what code?


dannytuppeny wrote:
If you install BE in the root, that's what happens - I'm running it at http://blogsformoney.com/ in the root without any problems. If you put it inside a folder (virtual or otherwise) like "App1", all paths will point in there, since it can't rewrite requests from a higher level folder.

Sep 2, 2007 at 2:06 PM
Edited Sep 2, 2007 at 2:13 PM
Thanks Mads, actually that's the first thing I changed, just removing that tilde in that line only. That indeed does remove the AppPath, except for these things (as far as I can see):

- The link to Author is still generated with the 'full URI' (not without the AppPath virtual folders)
- Same for the link to Categories
- It does seem to fail to load the CSS.axd handler, because all layout is messed up now
- All admin pages (not very important but still linking to that 'full' URI)
- (added) Whenever the feed is requested (syndication.axd), the site link in the feed links to the full URI

What class or controls should I change in order to remove those too? Thanks!


madskristensen wrote:
Change only the RelativeWebRoot from:

public static string RelativeWebRoot
{
get { return VirtualPathUtility.ToAbsolute("~/"); }
}

To:

public static string RelativeWebRoot
{
get { return VirtualPathUtility.ToAbsolute("/"); }
}

Sep 2, 2007 at 3:18 PM
Ok, just created a new site to test build 4292. Removing that tilde on that build does improve certain links:

- The syndication feed doesn't use that full AppPath anymore
- The author link in the post still points to the full path, file the widget does not

Strangely enough, the posts itself link to the full path again, hmm.
The CSS loading still does not work, while when I add the /?theme=Standard it does

Just letting you know ...
Sep 2, 2007 at 4:02 PM
@Mikey

Whoops, my bad. I've never come across anyting like that, I thought you actually had it in a subfolder! :-)
Sep 2, 2007 at 4:22 PM
Edited Sep 2, 2007 at 4:28 PM
@ Danny: No problem - it's just the way GoDaddy set this up (and boy, many people not liking this:)
http://blog.godaddyhosting.com/2006/08/11/multiple-domains-on-a-single-hosting-account--what-why-how.aspx#Comment

That's the primary reason I hate shared hosting. It's a tough trade-off to host it yourself (but uptime, bandwidth issues), use shared hosting (with hands pretty much tight together) or lease a dedicate server (which is an option later, but as startup company a bit too much $$$).
Sep 2, 2007 at 4:27 PM
@ Mads: Thanks so much for everything and congratulations with your new job btw. I highly appreciate all the efforts & time your putting into this.

As far as those full paths challenges, I noticed and changed the source in the App_Control to get rid of the tilde as well (quick & dirty, sorry). That fixed the URI refs for Category, Post and Comments as well now. Strangely, this was already working for the AuthorList, which uses:

AuthorList.cs
anc.HRef = Utils.RelativeWebRoot + "author/" + user.UserName + ".aspx";

While the CategoryList and MonthLists doesn't use this util. So I had to change it to this:

MonthList.cs
// anc.HRef = VirtualPathUtility.ToAbsolute("~/") + "?year=" + date.Year + "&month=" + date.Month;
anc.HRef = VirtualPathUtility.ToAbsolute("/") + "?year=" + date.Year + "&month=" + date.Month;

CategoryList.cs
// anc.HRef = VirtualPathUtility.ToAbsolute("~/") + "category/" + Utils.RemoveIlegalCharacters(key) + ".aspx";
anc.HRef = VirtualPathUtility.ToAbsolute("/") + "category/" + Utils.RemoveIlegalCharacters(key) + ".aspx";

Any reason why only the Author HRef uses the Util and the other don't?
Sep 2, 2007 at 4:32 PM
So with those paths fixed, the only (big) thing I messed with removing that AppPath is loading the CSS file: the themes simply don't work except when I request the page with /?theme=standard. Something tells me this is caused by this line in the CssHandler.cs

string file = context.Server.MapPath(Utils.RelativeWebRoot + "themes/" + BlogSettings.Instance.Theme + "/" + context.Request.QueryString"name");

Since I removed that ~ in the Utils.cs, it simply doesn't render/load the CSS.

Sorry for this truckload of posts, I'm finally gonna enjoy the weekend and relax ;-)
Sep 2, 2007 at 8:32 PM
Ok enough relaxing now - I just couldn't stand the fact the CSS theme wasn't loading now. After using Fiddler2 and seeing what HTTP traffic was going on, I noticed the request for this one noly: /themes/Standard/css.axd?name=style.css - turned into an error 500.

After disabling the 'trim stylesheets' setting, the theme is displayed!

I assume this has been caused by some File.IO request in CssHandler.cs that my medium-trust host doesn't allow. I can live with untrimmed stylesheets I guess, as long as those unwanted application paths are completely invisible to visitors.