Did you add a reference to an external library in the Umbraco project?
Typically, stuff like you described should be called in Umbraco render controllers, authentication even in the filter, or before Umbraco page execution.
Hi Alex,
tank you for the answer and sorry for my delay.
The problem is that when I open a page I must do some checks (ex. on login state, members, and other things).
So...I tried to create a custom surface controller but when I try to call it with @Html.Action("ChecksBeforeRenderPage","AFController"), but I receive some errors
I tried to create my custom render mvc controller but I cannot call my custom method.
What I wrong?
Can you give me a simple example how can I do that?
'Umbraco.Web.PublishedModels.AFMemberGroup' does not contain a definition for 'Username'
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Umbraco.Web.PublishedModels.AFMemberGroup' does not contain a definition for 'Username'
Source Error:
Line 5: Layout = null;
Line 6:
Line 7: @Html.Action("CheckSSOAuth","ADFS");
Line 8: }
Line 9: <!DOCTYPE html>
Source File: C:\inetpub\wwwroot_intranet\Views\ADFSLogin.cshtml Line: 7
...
var CurrentMember = Members.GetByUsername(UserInfoCookieValue["username"].ToString());
with this code (that I safely use in other surface controller):
var CurrentMember = Services.MemberService.GetByUsername(UserInfoCookieValue["username"].ToString());
but I receive the following error
'Umbraco.Core.Services.IMemberService' does not contain a definition for 'GetByUsername'
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Umbraco.Core.Services.IMemberService' does not contain a definition for 'GetByUsername'
Source Error:
Line 5: Layout = null;
Line 6:
Line 7: @Html.Action("CheckSSOAuth","ADFS");
Line 8: }
Line 9: <!DOCTYPE html>
Source File: C:\inetpub\wwwroot_intranet\Views\ADFSLogin.cshtml Line: 7
...
Umbraco 8 - How to call custom external methods from view
Hi to all,
I'm trying to call some external methods that return a bool value
I already write the methods but a I can't call them from the view in umbraco 8.
These methods must be called before each page is displayed and check different things (ex. authentication, cutom membership group, etc.)
Can anyone help me?
Thank you
A.
Hi Adriano
Did you add a reference to an external library in the Umbraco project? Typically, stuff like you described should be called in Umbraco render controllers, authentication even in the filter, or before Umbraco page execution.
Can you maybe provide code examples?
Thanks,
Alex
Hi Alex, tank you for the answer and sorry for my delay.
The problem is that when I open a page I must do some checks (ex. on login state, members, and other things).
So...I tried to create a custom surface controller but when I try to call it with @Html.Action("ChecksBeforeRenderPage","AFController"), but I receive some errors
I tried to create my custom render mvc controller but I cannot call my custom method.
What I wrong?
Can you give me a simple example how can I do that?
Thank you A.
Did you add a reference to your external library on your Umbraco installation? Why you are not able to call your custom method? what is the error?
Thanks,
Alex
Yeah, I referenced the library in the view
This is my code:
View
Controller
With this code, I receive this error:
The code that throw the excepton is:
So I also tried to change this code:
with this code (that I safely use in other surface controller):
but I receive the following error
I also tried using RenderMvcController...but nothing. I have same problems.
I changed the title of the post, because I don't need to return a bool but to view the page
Hi to all and sorry for delay.
I want to share with you that I found the solution by completely changing my approach.
My Controller now inherits from UmbracoController
I created various (static) methods to do all operations and now I can call them directly from views.
The solution was easier than I thought
A.
is working on a reply...