Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routing with Two Different Sites #437

Closed
aatmmr opened this issue Nov 17, 2018 · 4 comments
Closed

Routing with Two Different Sites #437

aatmmr opened this issue Nov 17, 2018 · 4 comments

Comments

@aatmmr
Copy link

aatmmr commented Nov 17, 2018

Hej Community!

I got somewhat lost and can't wrap my head around the following:

I have a simple scenario with 2 Sites, the DefaultSite and a custom MaintenanceSite. Each has a single page with a couple of Fields, such as, StringField etc. Her comes the problem: I cannot access the page of the Site that is not set as default. If I call the slug of the non-default page / site directly the respective Action is called, however, an id of 00000000-0000-0000-0000-000000000000 is passed to the action.

The pages are both available in the database with the expected slug.

In CmsController.cs I have the following Actions to get the request

[Route("maintenance")]
public IActionResult MaintenancePage(Guid id) 
{
     var model = _api.Pages.GetById<Web.Models.Pages.MaintenancePage>(id);
     return View(model);
}

[Route("test")]
public IActionResult TestPage(Guid id)
{
     var model = _api.Pages.GetById<Web.Models.Pages.TestPage>(id);
     return View(model);
}

The version of Piranha is the latest, namely 5.2.1.

Am I misunderstanding anything?! I checked the routing documentation and as I far as I understood, the slug should be found and the route generated accordingly.

Any help appreciated :)

@tidyui
Copy link
Member

tidyui commented Nov 17, 2018

Hi there! You can't have more than one site on the same hostname. If the pipeline can't find any site that specifically specifies the requested hostname then the default site is used (this is the standard case). You can use sites for several purposes, for example subdomains:

  • Default Site (empty hostnames)
  • Maintenance Site (maintenance.myhostname.com)

Or folder/suffix mapping for language sites, for example

  • Default Site (empty hostnames)
  • Swedish Site (myhostname.com/se)

@aatmmr
Copy link
Author

aatmmr commented Nov 18, 2018

Thank you for the quick reply! I tried both, however, no success yet.

I set the hostnames / sites as following (specific dev example):

  • Default Site (empty hostnames) - set also as default of installation
  • Maintenance Site (localhost:5001/maintenance)

When I reload the page at localhost:5001 the maintenance page is loaded. If I specifically call localhost:5001/test the controller action is found but again with id 00000000-0000-0000-0000-000000000000.

The ultimate goal is actually subsites for languages and my thinking was to catch the user culture / language and route to the matching subsite.

@tidyui
Copy link
Member

tidyui commented Nov 18, 2018

Let me try to do a setup of your case! This will be good input to the documentation as well

@aatmmr
Copy link
Author

aatmmr commented Nov 18, 2018

Great @tidyui - Thank you very much for you efforts!

I played a little with the settings and it seems that I cannot leave a hostname empty when another site has a specific hostname (with suffix) assigned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants