Link to home
Start Free TrialLog in
Avatar of oslonet
oslonet

asked on

httpwebrequest trigger an httphandler, no response wanted

Hello,

we currently have two webservers, i'm trying to make cache system which makes us able to delete a key from the cache in both servers and on different app pools. What i have done is to create a httphandler which i call with querystringparameter called cacheid.

I therefore need to send a request to the httphandler. I see that i need to wait for the response for the http handler. is there a way to skip this. I just want the request to be sent. then right away, free alle resources and contine the executing of the code.my code now lookes like this.
public void DeleteGlobalCacheID(string cacheID)
        {
            DeleteLocalCacheID(cacheID);
 
            foreach (WebServer ws in WebServers)
            {
                foreach (WebApplication wa in WebApplications)
                {
                    DeleteRemoteWebApplicationCache(ws, wa, cacheID);
                }
            }
        }
 
        private void DeleteRemoteWebApplicationCache(WebServer webServer, WebApplication webApplication, string cacheid)
        {
            string url = webServer.Url.ToString().Remove(webServer.Url.ToString().Length-1) + webApplication.Path.ToString() + "GlobalCacheHandler.axd";
 
 
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
            req.Method = "POST";
            req.ContentType = "application/x-www-form-urlencoded";
            string data = "cacheid=" + cacheid ;
            req.ContentLength = data.Length;
 
            SendRequest(req, data);
        }
 
        private void SendRequest(HttpWebRequest req, string data)
        {
            StreamWriter stOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
            stOut.Write(data);
            stOut.Close();
        }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of MogalManic
MogalManic
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial