I've an application which has several C# projects, as following
- CRM.DomainLogic
- CRM.Web
- Warehouse.DomainLogic
- Warehouse.Web
- ,...
Each web project such as CRM.Web has its own 'html views' and 'js controllers' and there are several other types of static files.
To make deployment easier I'd like to use Html5 manifest.
So, To make separated deployment across projects possible, I've used iframes. As a result with changes of CRM.Web, clients will get CRM files, and there is no need to download Warehouse.Web files again!
Steps:
1- I've a Web API method that returns all names of Web assemblies, for example CRM.Web and Warehouse.Web
2- I've another Web API method that gets the assembly name as a parameter and return manifest file content which points to files which are located on that project.
public HttpResponseMessage GetManifestByAssemblyName(String assemblyName)
Codes are omitted here.
response.Content = new StringContent(manifestBody.ToString(), Encoding.UTF8, "text/cache-manifest");
3- at client side I create a new iFrame for each assembly and set the src to another web api method which return html body that it's manifest is assigned to the address of WebAPI method that returns manifest body(GetManifestByAssemblyName)
String result = String.Format
(@"<html manifest='{0}'> </html>", "/api/AppManifest/GetManifestByAssemblyName?assemblyName=" + assemblyName + ".manifest");
response.Content = new StringContent(result, UTF8Encoding.Default, "text/html");
The code of iFrames:
var htmlPageUrl = "/api/AppManifest/GetHtmlContainerForManifestByName?assemblyName=" + name;
var iFrame = document.createElement("iFrame");
iFrame.setAttribute("src", htmlPageUrl);
iFrame.setAttribute("sandbox", "allow-same-origin");
iFrame.setAttribute("seamless", "seamless");
document.body.appendChild(iFrame);
When I run application, it gets assembly names, and then creates iFrames, and each iFrame gets its own manifest automatically.
But the window.applicatioCache.status is 0 which means it has no cache.
When I go resources page, I can see followings:
But when I request one of those files which are cached, the request will not use cache.
I know that there is no reference for my work on the web and this is totally based on my ideas, and I know some security restrictions may appear here, but is there any solution to fix a problem?
Thanks in advance.
Note: You can download sample application source code here.
Then press Ctrl+S to save the file, and read Index.html notes first.