none
How to WCF iis hosted application to run without any network call ? RRS feed

  • Question

  • I wrote some WCF application that expose restful service. 

    This application bring the information from file and on any restful call its return some data from this file. 

    I trying to make my application to read the file before any first restful call but i can't find any way to do it. 

    The only thing that i found is to popup the reading file method on the first time that any restful method will call - and by define the WCF interface as 


           [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.Single)]



    I don't need to read again and again from the file - and i can use one reading and keep the data on the memory. 

    But the first reading .. this can't be done in the restful method call 

    Any help please .. 

    Thanks.
    Thursday, February 9, 2017 4:48 PM

All replies

  • Hi ronili2,

    This forum is to Post feedback, questions and suggestions related to Released (RTM) versions of WCF Data Services Framework. Since your issue is more related to WCF, we'll move it to WCF forum for suitable support.

    Thanks for your understanding and cooperation.

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, February 10, 2017 6:43 AM
  • Hi ronili2,

    >> But the first reading .. this can't be done in the restful method call

    For this requirement, I suggest you try Global.asax, and you could follow below steps.

    1. Right Click the WCF project->Add New Item->Global Application Class

    2. Add your code which reads file to the Application_Start in Global.asax

            public static string value = "";
    
            protected void Application_Start(object sender, EventArgs e)
            {
                //this will run when this application start
                value = "Hello World";
            }
    

    3. Access the data from your Rest Service

            public string GetValue(int value)
            {
                //access the data in Global
                System.Diagnostics.Debug.WriteLine(Global.value);
                return value.ToString();
            }

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, February 10, 2017 9:16 AM