简体   繁体   中英

Visual Studio 2013 caching older version of .js file

I am working on a small web api project in Visual Studio 2013 Ultimate. Windows 2013. Internet Explorer 9. When I run (debug) from VS using the internal web server (I guess that is IIS Express, now), I am finding that the changes I am making (and saving) to a javascript page are being ignored. Placing a breakpoint in the javascript shows the older code without my changes.

CTRL+F5 does not force the application to use the currently updated page. Checking the page in, then checking it back out often works. Is there some setting or trick that will help me out here?

Clearing the cache history seemed a bit excessive and I don't want to do that all the time.

The following solution worked me in Internet Explorer: First enable script debugging:

  1. Tools menu -> select Internet Options
  2. On advance tab uncheck "Disable script debugging (Internet Explorer)"

Then make sure you get the newest page:

  1. From the Tools menu choose Internet Options.
  2. On the General tab, under Browsing history, click Settings.
  3. Under "Check for newer versions of stored pages" make sure "Every time I visit the webpage" is selected.
  4. Click the OK button.

If somebody has this problem and ctrl+F5, clearing browser's cache, restarting debugging, changing browser, changing web.config and rebuilding project don't help, then there is one last thing that works (at least for me): restart Visual Studio .

Also changing debugging port on local IIS Express helps but this is far more painful if working in a team or using Azure Active Directory etc.

Only solution that worked for me was changing the javascript file name and updating the bundle configuration to point at the new file. I tried everything else from restarting my pc, deleting bin/obj/cache/etc, CTRL F5, restart IIS, and so on.

If I'm correct you should build (ctrl+shift+b) your project before debugging. This web server runs in the background on a port of choosing whenever you start in debug mode. You can close the task(s) (process bar next to your clock) if you need a new session or press F5 in VS.

You can avoid using the built in web server if you have IIS (Express) or something similar. Go to RUN and type iis depending on your OS it's already installed. Otherwise try to install it in Control Panel > Programs or Features > Turn windows features on or off

  • add a website (site name, path, hostname)
  • add to your host file 127.0.0.1 hostname (c:\windows\system32\drivers\etc\hosts)

To debug your project in Visual Studio:

  • open your website on your hostname in your favourite browser
  • click on DEBUG
  • click on ATTACH TO PROCESS
  • find w3wp.exe
  • hit ctrl+f5 in your browser to start debugging server code

Depending on how your solution/project is setup, you can publish your project files directly to IIS if you choose to publish to File System . Right mouse click on your project and choose publish . Set it up from there.

If your Visual Studio is up-to-date you can publish single files with alt+$+p .

Hope it helps.

Locate the code section where the JavaScript file is loaded to the page and add a parameter string to the end for testing. For example:

Change src="../Resources/js/MyScriptFile.js"

To src="../Resources/js/MyScriptFile.js?v=23"

Every time you update your JavaScript file, you change the version number. This will force the browser to load your new version of JavaScript file. After you finished testing, You can remove the string "?v=23". The bonus, if you leave it there, the end user will not be required to refresh his/her browser cache after you deployed your code to production.

I keep getting this problem very often. Normally what I do is first get into the drive where the OS is installed (In my case C: ), and delete all the application.dll and application.pdb (it is stored in Windows\Microsoft.net\Framework\vx.x.xxxxx\Temporary ASP.NET Files ). Delete application.dll and application.pdb in the users\xxx . Get into the application directory and again delete application.dll and application.pdb . Clear the browser cache. Restart the system (cold restart). Build the application. Most of time found to be working. Note: I use DOS prompt for deleting since I'm quite used to it. But the user should have admin privileges. It's not a perfect solution but it works.

What worked for me was

  1. Shutdown Visual Studio 2013 update 2 (I have win 8.1 all 64 bit)
  2. Delete clear out "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files"
  3. Cleaned and Rebuilt solution
  4. Restart IIS Express. If using IIS just re start app and pool.
  5. Run in VS 2013 Debug (F5) it still loads the old file under Script Documents > Windows Internet Explorer > Page_Name.aspx
  6. Then F12 Developer tools clear Browser Cache (IE), I have the same issue in Chrome
  7. F5 in browser reload the page finally loads the changed JS script file with my debugger; entry and breakpoints set

So i had the same problem and i could avoid this by canceling the .ASP.NET-Server .ASP.NET-Server from Visual Studio for debugging from Visual Studio and restarting the debugging. Hope this helps someone.

I restarted Visual Studio and rebuilt the project, but the problem persisted for me -- the debugger continued to run an old copy of the .js file. The solution for me was to simply reboot the machine. (When all else fails...)

For reference, I'm currently using Visual Studio 2015.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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