0

I'm using Sitefinity (6.1), ASP.Net and the 4.0 framework.

We have a sitefinty website already hosted on IIS as a website. For licencing reasons we want to add a new site, also made with Sitefinity to the same website as a subfolder.

Lets say website 1 is Foo and the new website is called Bar.

The problem is when I get or use the relative path form Bar, I really get the path from Foo.

So atm I am using a hack to get urls to work. I use the relative path and then insert Bar man ually.

e.g. page is called home. ~/home resolves to http://www.Foo.com/home. when it should be http://www.Foo.com/Bar/home, so I just add the Bar in manually atm.

There must be some way in ASP.Net or Sitefinity or MVC to say this is my page, give me the full url.

Has anyone has experence resolving urls for websites in another website?

tereško
  • 58,060
  • 25
  • 98
  • 150
user1909158
  • 391
  • 6
  • 14

3 Answers3

1

Technically you're looking for an answer like this: How do I get the full url of the page I am on in C#

But with regards to Sitefinity you're bound to run into trouble cause it has many 'under water' references to the site root. Take a look for instance in the backend under Administration >> Settings >> Advanced >> Virtual Paths.

So you're bound to run into some cross contamination and end up with two broken sites.

While I'm not for dodging licenses, here's a few suggestions:

  • They do allow unlimited subdomains.
  • Install 'bar' as an IIS application that way ~/ will resolve properly.
  • Change Administration >> Settings >> Advanced >> System >> SiteURL settings.

That last option will allow you to set the site-root (not iis/asp.net level but sitefinity level) at which point you could retrieve a proper url through Sitefinity API with page.GetFullUrl();

Community
  • 1
  • 1
jbokkers
  • 952
  • 11
  • 18
  • The SiteURL settings sounds promising. I tried it locally, (I put a domain in the host text field) but it seemed to have no effect. Is it meant to if I put foo/bar in the host setting is ~/ meant to resolve to foo/bar? Do you mind giving an example please? – user1909158 Sep 27 '13 at 00:07
  • It's a means to tell Sitefinity that your website doesn't start at ~/ but at ~/foo. The ~/ will always resolve to whatever folder is configured at IIS server level. Say you configure IIS to have a website and in the root a sub folder named 'sub'. If in IIS 'sub' is merely a folder, .net will resolve ~/ to www.domain.com/ (the main website folder. If you configured 'sub' to be an application in iis then ~/ will resolve to www.domain.com/sub/ – jbokkers Sep 27 '13 at 07:27
0

If anyone is wondering I found a simple solution that works in all environments.

string url = node.Url.Replace("~/", "./");

Where node is of type SiteMapNode (but you can get the url however you want of course). That gives the correct path if there is a subfolder or not.

user1909158
  • 391
  • 6
  • 14
0

This string url = node.Url.Replace("~/", "./"); won't work if the page is not at the root level. For example for this url: "xxxx://www.foo.com/sitename/sitefolder/sitepage" it will return "xxxx://www.foo.com/sitename/sitefolder/home", instead of "xxxx://www.foo.com/sitename/home"

edu
  • 1