Reputation: 1
I am using ASP.NET and IIS for my website. Recently, I found Varnish Cache software via Google, an excellent caching HTTP reverse proxy.
Varnish Cache is installed on Ubuntu 16.04.1 and then I configure IIS connect to it. That's great.
Varnish Cache has function Purge to clear all cache of a specify page or all site. On ASP.NET, I wrote code create a Request to Varnish Cache Server with method PURGE and error occur: The remote server returned an error: (405) Method Not Allowed.
Here is my code:
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://IP-Address-Varnish-Cache-Server");
req.Method = "PURGE";
using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse())
{
// get the page data
using (StreamReader sr = new StreamReader(resp.GetResponseStream()))
{
string html = sr.ReadToEnd();
}
}
Please help me how to fix above error ? Thanks.
Upvotes: 0
Views: 513