簡體   English   中英

如何將Web響應存儲在global.asax中,以便我可以使用C#從wcf rest服務使用此響應

[英]How to store the web response in global.asax so that i can use this response from my wcf rest service using C#

我正在嘗試為我創建的項目創建global.aspx

<%@ Application Language="C#" %>

<script runat="server">

    void Application_Start(object sender, EventArgs e) 
    {
         var jsoniff = String.Empty;
        string fileName = www.abcd/xyc.com
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(fileName);
        request.Proxy = null;
        request.Method = "GET";
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        Stream responseStream = response.GetResponseStream();
        StreamReader reader = new StreamReader(responseStream);
        jsoniff = reader.ReadToEnd();

    }

    void Application_End(object sender, EventArgs e) 
    {
        //  Code that runs on application shutdown

    }

    void Application_Error(object sender, EventArgs e) 
    { 
        // Code that runs when an unhandled error occurs

    }

    void Session_Start(object sender, EventArgs e) 
    {
        // Code that runs when a new session is started

    }

    void Session_End(object sender, EventArgs e) 
    {
        // Code that runs when a session ends. 
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer 
        // or SQLServer, the event is not raised.

    }

</script>

現在,當我進行新的構建或重新啟動該項目時,將執行此global.asax。
在上面的腳本中,我添加了一個Application_Start,其中包括一個UR1並讀取JSON響應以結束。 現在,我需要在WCF REST服務中使用此jsoniff。
我如何在我的REST服務中調用jsoniff,以上實現是否正確。
提前致謝

您為什么不使用AJAX? 對於客戶端編程,這將是更可取的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM