I created a document type called Language (alias name is language).
I created a content called EN and I can access it thorught http://mywebsite/en
I created a controller:
public class LanguageController : RenderMvcController
{
public override ActionResult Index( RenderModel model )
{
Debug.WriteLine( model.CurrentCulture );
return base.Index( model );
}
}
I put breakpoint on line where is Debug.WriteLine and when access the url: http://mywebsite/en
I created in same project with umbraco. In MVC Application (where is Umbraco already installed), I created a folder called Controllers and there I put that controller.
It looks like it can't find the controller.
Or maybe there's another route hijacking in place.
Something related to languages maybe?
Did you define multiple languages or cultures?
I created simply a document type called language... I could rename to other string. if help...Do I have register something when application starts or something similar ?
If the name of your DocumentType is Language (alias = language), there's no reason to rename it.
And there is no registration involved either.
Just to verify if Language as name would be a problem, I've tried it myself (in Umbraco 7.4.3) with a document type named Language, a content node named EN and a controller called LanguageController (in my case defined in a class library).
After rebuild and run, the LanguageController.Index method is being called successfully when going to the page (http://mywebsite/en)
Your page renders fine, even though it does not reach your controller code?
What is the name of the template being used for the published EN node?
From your url, it looks like Products does not have DocumentType Language but a DocumentType that is a child of DocumentType Language.
(Otherwise, the url would be http://mywebsite/products)
For another DocumentType you need another Controller with the (alias)name of that DocumentType.
Create a controller for route via template
Hi,
I created a document type called
Language
(alias name islanguage
).I created a content called
EN
and I can access it thorughthttp://mywebsite/en
I created a controller:
I put breakpoint on line where is
Debug.WriteLine
and when access the url:http://mywebsite/en
then that breakpoint is never reached.
I read this page ( how mapping works ):
Where is my mistake ?
Where did you create the controller?
In case you created it in a seperate class library, make sure you add a reference to that library in your project.
I created in same project with umbraco. In MVC Application (where is Umbraco already installed), I created a folder called
Controllers
and there I put that controller.The code you wrote for the controller is ok.
It looks like it can't find the controller. Or maybe there's another route hijacking in place. Something related to languages maybe? Did you define multiple languages or cultures?
I created simply a document type called
language
... I could rename to other string. if help...Do I have register something when application starts or something similar ?If the name of your DocumentType is Language (alias = language), there's no reason to rename it. And there is no registration involved either.
Just to verify if Language as name would be a problem, I've tried it myself (in Umbraco 7.4.3) with a document type named Language, a content node named EN and a controller called LanguageController (in my case defined in a class library).
After rebuild and run, the LanguageController.Index method is being called successfully when going to the page (http://mywebsite/en)
Your page renders fine, even though it does not reach your controller code?
What is the name of the template being used for the published EN node?
And what version of Umbraco are you using?
I'm using version 7.4.2... Strange thing...
Although https://our.umbraco.org/forum/using-umbraco-and-getting-started/75998-update-to-742-all-custom-hijacked-controllers-stopped-working is not exactly about this scenario, there are other routing related scenarios that have been fixed in version 7.4.3.
Maybe give that version a try?
I make it works to link to
Index
action ofLanguageController
class.I had an old route definition and I removed it.
So, for
Index
works.I have another question.
If I go to
http://mywebsite/en
thenLanguageController
is instantiated andIndex
action is called.I created a sub-node for
en
calledproducts
and url ishttp://mywebsite/en/products
I created
Products
action but it is never called. I haveProducts
as template.Why ? What is the logic ?
From your url, it looks like Products does not have DocumentType Language but a DocumentType that is a child of DocumentType Language. (Otherwise, the url would be http://mywebsite/products)
For another DocumentType you need another Controller with the (alias)name of that DocumentType.
is working on a reply...