Does launchUriAsync work with .edu sites? - windows-8

I've created a JavaScript Windows Store blank app, and added the following code into it.
var url = new Windows.Foundation.Uri("http://www.google.com")
Windows.System.Launcher.launchUriAsync(url);
when debugging my program the above launches google without fail, but if I put a .edu site or something that ends in .aspx, the site won't launch.

I'm not able to reproduce this. Perhaps there's something in how you're doing this that's causing the issue.
To try to repro, here's what I did.
Started with the JavaScript Blank app template.
Added a button to default.html, on the line following the <p> element: <input id="Button1" type="button" value="Launch" />
Added an event handler for the button in default.js, just after the call to WinJS.UI.ProcessAll: document.getElementById("Button1").addEventListener("click", launchUri);
Added the launchUri function, as follows, to default.js:
launchUri:
function launchUri() {
var uri = new Windows.Foundation.Uri("http://www.communitymegaphone.com/Default.aspx");
Windows.System.Launcher.launchUriAsync(uri);
}
Works fine for me, both with aspx (as shown above) as well as for .edu addresses.
If you're still not able to make it work, please post some additional code for context.
Hope that helps.
For more info on Windows Store app development, register for Generation App.

Related

submit button not working when generated from AJAX

I got an ASP NET Core RazorPage having a button which asynchronously replaces a part of the given HTML using an AJAX request.
Besides some text content it renders another button which is intended to post back the side when clicked. It is surrounded by a form element.
However, clicking the button I receive an HTTP 400 with the information "This page isn't working" (Chrome). Other browsers like Firefox return an HTTP 400 as well.
The relevant HTML with the button which has been created by the AJAX call is the one below:
<form method="post">
<button class="btnIcon" title="Todos" id="btnTodos" formaction="PersonManagement/Parts/MyPageName?handler=PerformTodos">Execute action</button>
</form>
As the url exists (I doublechecked it using the browser with a simple GET) I wonder whether the issue could be due to some security settings along with the browser or is there anything I am perhaps missing out here?
Thank you for any hint
Two things here first add this attribute to your form asp-antiforgery="true", then send it's value to the server in your AJAX post request.
jQuery magic starts here :)
token: $('[name=__RequestVerificationToken]').val(),
Antiforgery is ON by default since .net core 2.0 (as far as I remember), so if you do AJAX post you need to send the antiforgery token with each request.
Let us know if it helps. Spread knowledge don't hide it just for yourself :P
Finally I came across a very interesting article from Matthew Jones at https://exceptionnotfound.net/using-anti-forgery-tokens-in-asp-net-core-razor-pages/ about Anti-Forgery Tokens in Razor pages. Worth reading, indeed.
However, independently from that article what solved my issue was simply not to add the <form .. element at the client-side, but already at the server-side. As there is no need for me to explicitly adding it at the client-side, but only the button itself, this is a solution for me which works properly.
A brief summary of my scenario now:
There is a Razor Page containing usual cshtml content along with a <form method="post"..
Some anchor elements also are included, one is triggering a JQuery AJAX call to the server
The JQuery call comes back from the server with some additional HTML including the post button which which I add to the existing HTML.
The button is being rendered inside the now already existing
Clicking the button causes the page to post back in the wanted manner and executes the handler as intended.
Thanks again Stoyan for your input and help with that.

.innerHTML does not work on Windows Phone browser

I have a problem with a label field on my HTML page. I have set a label as below:
<label id="labelid" class="required control-label">Old Label Value</label>
Based on some other form input, I am trying to change the value of the label using javascript. The code for that is:
function change()
{
document.getElementById(labelid).innerHTML = "New Label Value";
}
For some reason, this works fine on a desktop browser. It also works fine on IOS and Android phones. But when i view this HTML page on a windows phone browser, the new value is not visible.
Please advise. I must be doing something silly, but i cant figure it out.
The basic objective is to update a label based on what the user has typed in a text field. Please let me know if there is another way of doing it instead of using labels.
Try this code. You didn't have quotes around labelid..
function change() {
document.getElementById("labelid").innerHTML = "New Label Value";
}
In reference to Windows phone browser, Mark Chamberlain had these comments to a similar issue:
"Standard Javascript injection is not enabled; most likely due to risk of attacks, web site spoofing etc. If you need to customize a web site that you own, you should implement your changes on the web site (server) side."
This could possibly extend to adding/deleting/modifying HTML is my interpretation.
From this link: https://social.msdn.microsoft.com/Forums/windowsapps/en-US/94d4a806-3eca-411e-adda-9e0fa8a6f467/how-to-inject-or-insert-the-javascript-code-in-webbrowser-windows-phone-7?forum=wpdevelop

ViewStateException - Validation of viewstate MAC failed - Sitefinity ASP.NET MVC with Jquery Mobile

I am getting this error most of the time when I submit my form. I am using Sitefinity 6.2 with ASP.NET MVC 4.0 and JQuery Mobile.
As I have Sitefinity in Hybred mode I am using the #Html.BeginFormSitefinity() command to create the form. On the Controller I have my action with the [HttpPost] attribute. The code always hits my default action on the controller with no problem. No matter what I put in the form when I submit I only get an error message on the page...never hits the HttpPost action.
I've looked around and there are many pages with fixes for the MAC failed issue, but none are working for me. I have a machine key in the web.config and I am NOT going to set enableViewStateMac to false as that is a security hole.
OK I tried working with both of the below solutions but they are both really bad. Here is what I am doing now, which is still not great, but I have Sitefinity, MVC, and JQuery Mobile all on the same page and forms are not giving me View State Exceptions anymore.
First thing is that adding data-ajax="false" is not enough, for this to work you need to disable Ajax before JQuery Mobile starts. So, to do this you need to add in this script BEFORE the JQuery Mobile File loads but after the JQuery file loads.
$(document).bind("mobileinit", function () { $.mobile.ajaxEnabled = false; });
After doing this I then do not use the Sitefinity Begin Form, I just JQuery to change the form on the main page to have the correct action.
<script>
$("#aspnetForm").attr("action", "Home/Login");
</script>
Together this means that there is a complete page load for each page change, and form posts use the form declared in my WebForms Master Page.
-Old Answer -
Actually...what I have below is not working. What I am
currently doing is really ugly but is usually working.
As long as the user enters the site from the home page then the home
page is the Jquery Mobile first page. The view state errors that I
was getting was because it saw the current page as the first page and
the form submit was to the active page. What if the controller for
the home page was just set to handle ALL HTTPPost calls? I have
removed the #Html.BeginFormSitefinity() from all the views with forms
and am just using the form on my top level masterpage. Then I add in
code on the view to change the action of this form to point to the
main page controller. ex
<script>
$("#aspnetForm").attr("action", "Home/Login");
</script>
Once I made this change the forms are not throwing view state
exceptions...as long as the home page is the Jquery Mobile first page.
If the user comes in from a different page then all is scrambled.
Don't have an answer for that yet.
Really Old Answer -
OK, think I have found it. I read somewhere, lost the link now, a
list of issues that can cause the error message. One of them is the
form being submitted from a different page.
I looked at the error message I was getting with Fiddler and noticed
that the Referer was my home page but the URL of the form post was the
URL for the page with my form. In stead of browsing through my site
to the page with the form I typed the URL in the address bar. I tried
submitting my form again and now it works!
So, this is an issue of Sitefinity and JQuery Mobile fighting it out.
When asp.net MVC is run in Hybred mode in Sitefinity it is actually
run in a Web.Forms master page that contains a form. When you use the
#Html.BeginFormSitefinity() to add a form to the view it is actually
just adding a div and then using AJAX to submit the form on the
Web.Forms master page.
JQuery Mobile loads up the first page that you visit, but later pages
are just injected into the existing page. So, there are multiple
data-role="page" divs loaded up in the DOM, inside of the Sitefinity
Web.Forms Master Page.
This all together is causing the form to post with the URL of the
active data-role="page" but the server sees that it is being refered
from the original page I loaded up. So, if I went to the page with
the form first all would work, start at any other page it does not
work.
Now that I know this I can put in data-ajax="false" on the link to the
page with the form and all looks to be working. This will cause
JQuery Mobile to not inject the target page into the current page but
will load all fresh with the target.
data-ajax="false" is the answer!

Rally 2.0 example provided will not load

So I've recently decided to upgrade to Rally SDK 2.0. I'm using the starter kit and following the directions on the website. All I've done so far is added:
launch: function() {
this.iterationCombobox = this.add({
xtype: 'rallyiterationcombobox'
});
}
To the js file. Ran the rake command, loaded App.html into a browser. It is blank. According to the website, there should be a small combobox on the top left of the screen. I don't know what I missed, I assumed the example would work as the website displayed.
edit I should add that this isn't the only thing contained in the HTML file. I just meant that rake generates an HTML file at the beginning that adds //Add Code Here to the javascript function. I meant that the above code is the only tihng I've changed.
I tested your code snippet and it works in my testing. Did you paste the App code into a Custom HTML App in Rally? Or are you running outside of Rally?
If the latter, you'll need to modify the src attribute of the script tag in App.html:
<script type="text/javascript" src="https://rally1.rallydev.com/apps/2.0p5/sdk.js"></script>
So that it contains a fully-qualified reference to the AppSDK2 JS library.
The AppSDK API Docs have some good Examples of simple starter Apps. The Grid examples are good places to start. You can click on the "View Source" link within any of the Example apps and see the source code.

Where to put js code for polling tile notifications for windows8 js&html app

http://msdn.microsoft.com/en-us/library/windows/apps/hh761476.aspx
Those instructions are great, but where do I put the below code (grabbed from article above)? In my default.js file, above the app.addEventListener("activated", function (args) { line of code? Below that line? Elsewhere? Thanks Microsoft, but tell me where to put the code!
var notifications = Windows.UI.Notifications;
var recurrence = notifications.PeriodicUpdateRecurrence.hour;
var url = new Windows.Foundation.Uri("http://mytileprovider.com/tile.xml");
notifications.TileUpdateManager.createTileUpdaterForApplication().startPeriodicUpdate(url, recurrence);
Ideally this would just be a manifest setting with a dropdown of "Frequency" and an input box for the url to grab it from. That would be oh so helpful and convenient.
The answer is... it depends. :)
Where do you want to set up the tile and the polling? Is it an "always on" feature that is core to your application? If so, then put in inside the activated event for your default page (usually inside default.js). Or maybe you are adding tiles based on content that the user interacts with (i.e., selecting a stock to pin to the Start page). In that case, you would put that code inside the page that handles the user action that.
The simple answer is... inside the activated event. The real answer, as you can see, can be more involved.