Webmatrix functions RRS feed

  • Question

  • Don't know if this is the right forum. Couldn't find one specific for WebMatrix?

    I want to set up global functions like the PHP include.
    I can use the @Functions block OK but this only works when the function is called on the same page - unless I am missing something?
    I want to be able to set up a function so that it can be called from any page on a site.

    Can anyone help?



    Sunday, November 2, 2014 12:37 PM


  • Hi,

    You can define the method in global.asax file like this:

    public class MvcApplication : System.Web.HttpApplication
            protected void Application_Start()
            public static string GetPhoneNumber()
                return "012345 678 910";

    And then call it like following:


    In addition, please refer to the similar discussion:

    #extend htmlhlper:

    Hope it is helpful to you.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Pengzhen Song Thursday, November 13, 2014 12:07 PM
    Monday, November 3, 2014 5:49 AM