Windows Store WinJS app - how to pass query string, hash parameters to start page - windows-store-apps

We have a SPA web application that we're trying to convert into a WinJS project as a native Windows Store app. For most part, the Javascript is working except for DOM manipulations deemed unsafe.
One thing that does not appear apparent is, how can the start page of the app (e.g. index.html) be supplied with query string and hash parameters? Our site main page is designed to behave differently based on parameters.
e.g. index.html?contextId=xxxxx#enviroment=xxxxx
I tried adjusting the value in package.appxmanifest to no avail. It will throw errors on query strings, and hash parameters will silently not persist.
UPDATE: Project background
A brief about what our app does, and then why the above naive desire won't work and the answer below how we went about this issue.
Our web app is a highly-dynamic data-driven application that completely relies on data to figure out what to render. Therefore the ?contextId=xxxxx parameter is so crucial as it tells our system to load the data which further informs what kinds of visual components to load and it goes on recursively to form wildly different UIs.
We were looking to therefore find some means to supply these parameters like traditional command-line parameters to the same executable to produce different UIs. And thus different "apps" by mere changes in those parameters. Like a "config transform" mechanism for web.config in ASP.NET web projects, that would be most welcome.
However further testing showed it is not possible; a single Windows store app project has a GUID that is supplied into the packaged app bundle. Building the same project multiple times with different "build config" would just mean overwriting a previous installation since they are the same app with increasing version numbers. The answer details how we went about this.

Windows Store apps don't work with URI parameters when launched from their primary tile. In that case, you should make sure that the app defaults to suitable values, e.g., if you were thinking to supply defaults in the manifest, then default to those in the app's activation handler for the ActivationKind.launch case when eventObject.detail.arguments is empty.
There are two other ways to launch an app that can supply other arguments.
First is to launch via a secondary tile. When you create the tile from the app (which is subject to user consent), you supply the launch arguments. In your activation handler, for ActivationKind.launch, those args will be in the eventObject.detail.arguments property.
Second is to launch the app through a URI association. You use a custom schema for this, which is declared in the manifest. The app will then see ActivationKind.protocol and eventObject.detail.uri will contain the full URI including any parameters. A URI launch can be done from another app, by entering the URI into a browser address bar, or through a shortcut that a user could configure on the Start screen.

The first step is to convert our Windows (8.1) Store project into a Universal app structure, which would then spin off a separate Windows Phone WinJS project (this is nice when we wish to target Windows Phone later) and a shared project.
Practically everything from the Windows Store project is moved to the shared project (including default.html or index.html). What remains in the Windows Store project is a customised config.js carrying the parameters
window.customWin8 = {
contextId: xxxxxxxxxx,
customParam: 'xxxxxxxxxx'
};
The downstream modules that sense for query string/hash parameters would then fall back to this alternative object if it exists to pick up the data it needs.
Now, for every differing app we wish to deploy, that would for now seem to require a separate Windows Store project so it gets its own GUID and won't conflict with other apps. All these projects would reference the very same shared project thanks to the Universal structure Visual Studio affords. The only down side is it seems Visual Studio 2013 does not have a direct UI method to make this referencing to the share project and has to be hand code into the jsproj file.
<Import Project="..\Common.Shared\Common.Shared.projitems" Label="Shared" />
With this adjustment they can all build and package with their isolated "build config".

Related

Open application with browser link

We have a web application which is used to manage a list of main records in a database via a Spring Boot Web server talking to a back-end Java Server.
We also have a JavaFX standalone application which is used to graphically manipulate sub-records of these main web records, using a similar connection to the back-end Java Server.
We want to be able to launch this JavaFX application by clicking on a link next to each of the main records in the web interface. We would like to do this as seemlessly as possible.
At the moment the only way I can think that we can do this, is to use the Browser's 'Applications' set up to associate a particular MIME file type with the standalone JavaFX application, and somehow pass the UID of the record we click on as the 'file' being 'downloaded'.
Trouble is I'm not really sure what I should be googling for, to find out about this download process. For instance, does the browser pass the 'file' in a MIME message that is passed to the application, or does it save the 'file' in a temporary directory and then call the application with the temporary file path?
Has anyone done this sort of thing before, that could give us some pointers?
I don't have a turnkey solution but I think what you are looking for is a custom URI scheme (like the Magnet URI scheme magnet:, mailto:, or tel:).
Here is an article about launching applications using custom browser protocols and here is how to register an application to a URI Scheme on Windows.
You will have to modify the Windows Registry to link your custom protocol to an application, it looks like:
HKEY_CLASSES_ROOT
alert
(Default) = "URL:Alert Protocol"
URL Protocol = ""
DefaultIcon
(Default) = "alert.exe,1"
shell
open
command
(Default) = "C:\Program Files\Alert\alert.exe" "%1"

IsolatedStorageSettings after application update from store

I am writing my Windows Phone 8.1 Silverlight App (NOT RunTIME framework).
I have to questions:
Which is the App manifest file for Windows Phone 8.1 Silverlight? WMAppManifest or Package.appxmanifest? as my project contains both
I created a method in Mainpage of application which detects that is it the first time this application is running or not. If it is first time execution of this app, registry of 120 keys (IsolatedStorageSettings.ApplicationSettings) is created and app moves to WelcomePage.If the execution is not the firsttime, means user has opened this app before, it skips the registrycreation method and directly goes to homepage.
When I upload this version 1 of app to store and users install and use it. What when I add more keys to registrycreate method in version 2 and upload version 2 to store. How will be those new keys get created? Even, when user updates the app, the registrycreation method will never run.
The "Silverlight" app manifest is WMAppManifest.xml, but you still need to include the "RT" manifest Package.appxmanifest and, if you ever use any of the RT namespaces that require certain capabilities, you should check those capabilities in the Package.appxmanifest too. Eg "Internet (Client & Server)" if you are using things like Windows.Networking.BackgroundTransfer.
You'd need to add some code to check if the information or information structure has changed every time the app is run (or resumed), so that in the event of an update (and change in the keys), they get added, even if your "first run" code doesn't fire. Make sense?
If you know the keys numbers will always get bigger then watching the key count will work. You could also include a key with the version so you can tell which version the data was created with.
You can use Windows.Storage.ApplicationData instead of IsolatedStorageSettings in Windows Phone Silverlight 8.1. ApplicationData supports versioning with the ApplicationData.SetVersionAsync method so you can change the data format safely when you update the app.
Either way, when the app runs check if the data's version is the latest that the app knows about. If not then run your setup and migration code to add the new keys and replace the out-of-date ones.
The data version doesn't have to match the app version (you may update the app's version without changing the data). You can compile a data version constant into the app's data handling code and bump it whenever you change the data format.

How to prevent embedded manifest from being used?

I am working on many apps that uses RegFree COM Activation, everything works well except that one of the application is ran using an older technology that uses a JIT-type compiler.
To get RegFree COM working, i have to provide a manifest to the launching executable (correct me if i'm wrong) with my dependencies listed. All my other applications are built in-house and i have full control over my manifest (authoring and if i embed it, if i leave it Side-By-Side, etc). But this JIT-compiler (ala Java JRE) isn't mine and it already contains (embedded) a manifest.
I've extracted the manifest (using MT with -inputresource and -outfile), modified it and re-embedded it. It works like expected. However, having no ownership over this executable, i am worried about the legality of such a manipulation (modifying a third party's executable and redistributing it!) and would like to avoid having to do such a thing.
Also, i am worried that at some point this executable may be signed by the third-party and thus modifying the embedded manifest is going to break the signature.
Is there a way to have the sxs-loader look for another manifest first? It seems that if it finds one embedded, it takes it by default (which under most cases is fine).
Can i provide a configuration file or anything that would skip the embedded manifest and go for my side-by-side provided one (myExe.exe.manifest, instead of RT_MANIFEST resource inside myExe.exe) ?
You can only do that system wide as far as I know. Add that to the registry:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide]
"PreferExternalManifest"=dword:00000001
Make sure to trip activation context cache by updating last modified date on your executable, otherwise your manifest changes won't be picked up (renaming and renaming it back seems to work).
On Win XP external manifest is preferred over internal, but since Windows server 2003 Service Pack 1 they changed it to opposite.

How can I use a console application with my website in Visual Studio?

Please read the following in the Visual Studio 2012 context:
I have two projects--one is a website (File --> New Website) and another is a console application (File --> New Project --> Windows --> Console Application). I am the author of the former.
The standalone app fakes the input by hardcoding it, runs through some code, and creates an output. It uses dlls from a local installation of software that I have installed on my machine to generate this output.
I read on MSDN that I cannot add a console app to a website solution in a useful manner. So, if I compile the console app to output a dll instead of an exe, can I reference that dll in my website? How can I do this exactly? I would need to pass the input value from the website to the dll, and return meaningful results from the dll. Is this possible?
Yes, you describe a feasible way to solve this. You need to create a class library project, add source code from console application to it, except the the class that has static Main method and modify (add to) that source code such that there is a class that you will be able instantiate from the code in your web application after you add the class library assembly to the web application as a reference. This class will have a method with appropriate parameters, that you will call. All this assuming that the task that console application code performs is fast and will not create noticeable delay in the web application response. If the task takes a long time, you will either have to run it in a background thread or move it outside the web application - the latter is significantly more involved.

How to configure Netbeans code entry point when you use mod-rewriting

I am developing a website in PHP and I am using mod-rewrite rules. I want to use the Netbeans Run Configuration (under project properties) to set code entry points that looks like http://project/news or http://project/user/12
It seems Netbeans have a problem with this and needs an entry point to a physical file like http://project/user.php?id=12
Has anyone found a good way to work around this?
I see your question is a bit old, but since it has no answer, I will give you one.
What I did to solve the problem, was to give netbeans what it wants in terms of a valid physical file, but provide my controller (index.php in this case) with the 'data' to act correctly. I pass this data using a query parameter. Using your example of project being the web site domain and user/12 as the URL, use the following in the NetBeans Run Configuration and arguments boxes. netbeans does not need the ? as it inserts that automatically, see the complete url below the input boxes
Project URL: http://project
Index File: index.php *(put your controller name here)*
Arguments: url=user/12
http://project/index.php?url=user/12
Then in your controller (index.php in this example), test for the url query param and if it exists parse it instead of the actual Server Request, as you would do normally.
I also do not want the above URL to be publically accessible. So, by using an IS_DEVELOPER define, which is true only for configured developer IP addresses, I can control who has access that special url.
If you are trying to debug specific pages, alternatively, you can set the NetBeans run configuration to:
http://project/
and debug your project, but you must run through your home page once and since the debugger is now active, just navigate to http://project/user/12 in your browser and NetBeans will debug at that entry point. I found passing through my home page every time a pain, so I use the technique above.
Hopefully that provides enough insight to work with your project. It has worked good for me and if you need more detail, just ask.
EDIT: Also, one can make the Run Configuration Project URL the complete url http://project/user/12 and leave the Index File and Arguments blank and that works too without any special code in controller. (tested in NetBeans 7.1). I think I will start using this method.