I have looked for answers to this question, but I am not sure if I am asking it right.
I am looking for what do developers do in this situation:
I am developing an ASP.NET C# applications. I have CSS and SCRIPT files, and I am using jQuery. I install my application to the Web Servers (or I have my customer install them). If I have made any changes to my script files by adding some new jQuery or something, my customers don't get that effect after I do an update. I assume that the reason is that their browsers cache the file on the local computer and they do now download the new file from the server.
In my development environment I clear the cache when I close the browser and on IE I tell it in options to always load from the server. That way when developing I never have cached data.
What is the best practice to make sure that if I do make changes, those files get refreshed on the client computers after I do an update? Is there something in Code I can do?
I really don't want to change the filename and update all my script references.
Thanks,
Cory
The traditional way is to append a query string argument to the end of the reference to the css/script file path. For example, if you append a build number as the query string, each version of the software will make its own request for the relevant resource.
Related
I'm working on an app using Unity. This app is supposed to upload certain simple information at specific points, which is why my original plan was to just connect it to a Mysql database. Unfortunately Unity doesn't support the NET 4.0 framework and nothing I've tried seems to work.
Yes I could use PHP scripts hosted on my web server to add and pull information, but I'd rather do it all from the app itself if at all possible.
The data I need to record is pretty simple, IDs, ints, strings, nothing too complex.
So I'm now trying to look into alternatives to Mysql.
JSON
So far I have gotten SFTP to work (By using the Renci.SshNet library) and the app is now uploading files in my server's home directory. So my original idea was to just create JSON files with the data and edit them remotely.
Is this something that could be done with C#? How? Any specific resources?
The alternative to remote editing would be to download the JSON file, edit it locally, and then upload it again, but that doesn't sound like a very smart idea.
I have found this answer but it's unclear to me if it requires to send the whole JSON file to the server after every edit or if it's possible to just edit it from the app. Some clarification would be great.
SQLlite
I've also looked into SQLlite but I'm also unsure if it could be remotely edited.
I've Googled it multiple times but can't really find any useful information.
What are my options at this point? What should I use if I needed the equivalent of a Mysql Database that can be remotely edited and read?
You can start seeing into Google Firebase project
https://firebase.google.com/docs/database/unity/start
But unity 2018.3 does support Net 4:
https://learn.microsoft.com/en-us/visualstudio/cross-platform/unity-scripting-upgrade?view=vs-2017
https://blogs.unity3d.com/es/2018/07/11/scripting-runtime-improvements-in-unity-2018-2/
https://blogs.unity3d.com/es/2018/03/28/updated-scripting-runtime-in-unity-2018-1-what-does-the-future-hold/
So I'm tinkering with using Umbraco as a CMS for an MVC application. Of course, I run the site locally and publish to a server and use Umbraco for managing things like hero images, carousel text, and a few basic dynamic elements that are stored in Umbraco.
However, one can also modify the actual template .cshtml files as well through the Umbraco back office. The problem with that is that those changes won't be reflected locally, and any changes made in the Umbraco back office would get overwritten on the next publish.
Is there any way to 'pull' the changes made in Umbraco (without having to FTP in and download the entire site), or even better integrate it with git directly?
If I understood you correctly, Umbraco uSync package might help you:
https://our.umbraco.org/projects/developer-tools/usync/
It exports the changes in "uSync" folder locally - you can do this automatically or manually, and then you transfer those files on the server, and do import within Umbraco Dev section.
Yes use uSync for this but you should probably decide whether you edit your template files locally or on the server. Generally you would probably keep editing template files, CSS, js, locally and upload changes to your live site. However, if you are adding content, setting up a template for the first time, changing doc types, adding data types etc, these are all database changes so either; share the database on the server between your local and Server versions of the site; or use a tool like Courier or USync to replicate your changes between environments.
This question already has answers here:
force browsers to get latest js and css files in asp.net application
(23 answers)
Closed 8 years ago.
I'm maintaining an asp.net 3.5 website deployed on IIS 6.0 and I have made some fixes to a javascript file "scormapi.js" and should copy it (just this file) to the client website server. My problem is that the script reference to to this file with its version is injected into the page through server side code:
ClientScript.RegisterClientScriptInclude("DWScormAPI.js", ResolveUrl("~/Scripts/scormapi.js?Version=3.3"))
Which means that the client browser will use the cached file if I just do a copy of the file. Is there anyway to force the browser to use the new copied version of the file without recompiling and deploying the dll.
Thanks
EDIT:
I thought of adding to the aspx pages that uses the js file a tag that reference this js file with a different version number, or maybe using jquery $.getScript(). But in this case I would have two script references to the same file on the same page and I wonder if there is anyway to tell the page use this version of the file instead of that version.
NB: This is not duplicate question. I'm asking whether there is an alternative solution that avoids me modifying my server side code and then do a recompile and full deployment. The duplicate question some folks are referring to is just not what I'm asking about.
The only way to 'force' a browser to fetch a file instead of used its cached version is to change the URL in some way. In our system, our 'url injection' includes a query string with a timestamp - looks like "...something.js/140324" for a file that changed yesterday.
Here are some ideas for updating the js file for your users.
You could have the ?Version= have a value that changes every X minutes which forces the client to load a fresh js file every X minutes when visiting the website.
If you really must detect it server-side you could let the ?Version= have the value matching the last edit info for that file. E.g. let the server find the file on the system and examine last edit info and append that info to the ?Version= url part.
I'm developing a C# replacement for a legacy VB app for my company. The front end is basically a Web Browser control inside of a Windows form, serving offline content which is sometimes altered to include the user's data. Because there are 100 or more web files in the legacy app, we are going to reuse the web UI from the old application with a new C# wrapper around it, modifying them as needed.
My questions are about how to store and deliver the web content.
Does it make sense to copy the web files to a temporary folder and point the Web Browser control to the file:// address of the temporary folder?
Is there some kind of pre-built offline-friendly server framework that makes more sense than copying the files to a temporary folder?
I have the web source files in my project as resources, but I'm not sure if that is appropriate for my uses. Is it?
The legacy VB implementation alters the web files to inject data using Substring methods; it searches for magic strings and replaces them with the appropriate data. That code smells pretty bad, is there a better, more native data injection strategy I should look at?
Some background:
The data is presented using HTML\CSS\JS and also sometimes XSL.
The browser delivers content that is available at compile time.
I'm going to have to handle some events using c# code when users click on buttons of the page.
I'm free to choose whatever approach is necessary to implement the application.
Hosting
I would probably avoid using a temporary location for the web content it just seems a little crude. If there is no internal linking between your html pages and all the css/js is embedded in one file it may be easier to just use the WebBrowser.DocumentText property.
Another option I have successfully used as a lightweight embedded web server is logv-http, it has a pretty easy to configure syntax. If you want to configure against anything other than localhost it does require administrator privileges but it sounds like everything will be local.
var server = new Server("localhost", 13337);
server.Get("http://localhost:13337" ,(req, res) => res.Write("Hello World!"));
server.Start();
Templating
I think the string replaces aren't necessarily bad depends how many there are and how complicated they are trying to be, but for simple find replace it shouldn't be too hard to manage. If there are lots of replaces wrapping them into a RegEx should help performance.
Storing the web content as embedded resources is probably how I would go that way you can read them out at run-time do you pre-processing and then return either via the the web server method or direct into the DocumentText.
I have created a web browser in .NET [c#]. It is working fine but I am little confused with how to manage these things.. please help me in deciding how to implement it!
Where/How the cookies will be stored in my browser?
Bookmark?
History?
Pop Up blocker / other browser settings?
I can understand that the question is too general, but even your little suggestion will help me a lot.
Look at how other browsers handle cookies, they store it in the browsers temp (cache) folder
Bookmarks are just a key value list (at the very simpliest), key is a URL, value is the display name. Any place you can store a key/value list (like a database) would work.
History is just bookmarks that are automatically captured and ordered by date.
This depends on what you are using for the web browser control - if you are using the IE activeX control then you are stuck to sharing settings with it. This also means that you have a fantastic UI built for the settings though. If you have written your own then you need to store them somewhere, in a database for example.
I have mentioned database a few times, but I am not thinking a full MS SQL Server install, but rather something like SQLite.