简体   繁体   English

如何在没有任何网络调用的情况下WCF iis托管的应用程序运行?

[英]How to WCF iis hosted application to run without any network call ?

I wrote some WCF application that expose restful service. 我编写了一些WCF应用程序,公开了宁静的服务。

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. 我试图让我的应用程序在任何第一个restful调用之前先读取文件,但找不到任何方法。

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 我发现的唯一一件事是,任何宁静的方法都会在第一次调用时弹出读取文件方法,并将WCF接口定义为

   [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. 谢谢。

Using global.asax 使用global.asax

The global.asax file is also known as the ASP.NET “HTTP” application file. global.asax文件也称为ASP.NET“ HTTP”应用程序文件。 It is an optional file and if there is one, it needs to be in the root of an ASP.NET application. 它是一个可选文件,如果有,则必须位于ASP.NET应用程序的根目录中。 It contains code to handle application-level events raised by ASP.NET or HttpModules. 它包含处理ASP.NET或HttpModules引发的应用程序级事件的代码。 It is tightly coupled with the ASP.NET HTTP pipeline. 它与ASP.NET HTTP管道紧密结合。

You will want to utilize the Application_Start method. 您将要利用Application_Start方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM