So basically I have custom attribute where I need to pass two parameters.
I know how to do it in surface controller but how to you get node properties in main controller ?
public class LoginController : RenderMvcController
{
[IsLoggedInRedirect("/leverandoerer.aspx", "/boligorganisationer.aspx")]
public override ActionResult Index(RenderModel model)
{
return CurrentTemplate(model);
}
}
and the url parameters passed have to be taken from the Login document type. So how do i get model or currentpage there ? if not possible how it should be done other wise ?
Both ways you are getting it inside Action.
I need it outside.
[IsLoggedInRedirect(Currnet page does not work here, Currnet page does not work here)]
public override ActionResult Index(RenderModel model)
{
return CurrentTemplate(model);
}
I created custom attribute, that uses custom logic to authenticate the users and redirect him to specified landing page based on his parameters. I am using it quite a lot, so would not want to create many repeatable ifs inside it.
That is why attribute was a good choice, but now figured out that is hard to fetch umbraco data there.
Alright! but you can get the Umbraco value in your custom attribute then you have to change your custom attribute either you have to make one which will work for umbraco :)
MVC get node/model properties in main controller
Hi,
So basically I have custom attribute where I need to pass two parameters. I know how to do it in surface controller but how to you get node properties in main controller ?
and the url parameters passed have to be taken from the Login document type. So how do i get model or currentpage there ? if not possible how it should be done other wise ?
you should be able to access via CurrentPage.GetPropertyValue("yourproperty")
Other way is model.Content.GetPropertyValue("yourproperty")
I can get CurrentPage in Surface controller but not in the main controller.
In main non of the above works. Any more ideas ?
I cant see that why can you not access them but i tried like it and it works, what problem are you getting actually?
public class LoginController : RenderMvcController
{
//
// GET: /Login/
public override ActionResult Index(RenderModel model)
{
CurrentPage.GetPropertyValue("property");
model.Content.GetPropertyValue("property");
return CurrentTemplate(model);
}
}
i am using another way where i am using my custom model
public class MasterController : RenderMvcController
{
//
// GET: /Master/
protected ViewResult View(MasterModel model)
{
CurrentPage.GetPropertyValue("pageTitle");
return base.View(null, model);
}
}
Both ways you are getting it inside Action. I need it outside.
Hmm! thats the problem. No idea :)
Why do you want to use it in attribute? what actully do you want to achieve?
I created custom attribute, that uses custom logic to authenticate the users and redirect him to specified landing page based on his parameters. I am using it quite a lot, so would not want to create many repeatable ifs inside it. That is why attribute was a good choice, but now figured out that is hard to fetch umbraco data there.
Alright! but you can get the Umbraco value in your custom attribute then you have to change your custom attribute either you have to make one which will work for umbraco :)
So that was the question :) how do you make it work. You also cant access umbraco nodes inside custom attribute.
you can use like this.
umbraco.uQuery.GetCurrentNode();
umbraco.uQuery.GetNode(123);
Umbraco.Core.ApplicationContext.Current.Services.ContentService.GetById(1);
And that one worked ;)
Thanks a lot
Great! :)
is working on a reply...