Gee
Gee

Reputation: 165

How to fire a .cmd file on process.start from aspx.vb

I'm trying to fire a .cmd file to empty temporary internet files when I run my code. Everytime I write out a .html file it doesn't show the current changes unless I manually clear all temp internet files. Is it a way I can do this in my code behind?

This is what I'm using.

<code>
     Protected Sub Page_Load(sender As Object, e As EventArgs)
        Dim p As New Process()
        p.StartInfo.FileName = "../deleteTemp.cmd"
        p.Start()
    End Sub
   </code>

This is what's in my deleteTemp.cmd file

<code>
    RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
   </code>

Upvotes: 0

Views: 286

Answers (1)

pvanhouten
pvanhouten

Reputation: 782

A little more context around what you're trying to accomplish would be helpful, but if I understand your question correctly, you're trying to clear out your local browser cache using server side code in order to address the issue of caching of static html resources. You won't be able to clear a browser cache from the server side like that for numerous reasons. My recommendation would be to add meta tags to those HTML pages to address caching like this:

<html>
<head>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
</head>
<body>...</body>
</html>

You can also set headers within the web server to disabling caching of certain file types. This differs by the version of web server you're using, but you can read up on how to do that if you're using IIS here: http://support.microsoft.com/kb/247389. If these are .aspx pages that you're trying to disable caching on, you can do that using server-side code in the page init or load by doing something like this:

HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);

Hopefully that helps with what you're trying to do.

Upvotes: 3

Related Questions