Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Chart API breaks when I use Authentication
    text
    copied!<p>I am using MVC 4 and the google chart API, when I enable authorization in my web.config the interactivity of my chart breaks. (Renders fine, but when I click a link for more information throws up an error not knowing what "google" is.</p> <p>Below is my vbhtml page;</p> <pre><code>@Code ViewData("Title") = "Home Page" End Code @Section Head @Scripts.Render({"https://www.google.com/jsapi"}) End Section &lt;h3&gt;Welcome to XXXXXXX&lt;/h3&gt; &lt;p&gt; This will be a multi-system dashboard &lt;/p&gt; &lt;div id="vacancyRates"&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt; google.load('visualization', '1.0', { 'packages': ['corechart'] }); google.setOnLoadCallback(drawChart('vacancyRates')); function drawChart(container) { $.ajax({ url: "/Home/GetVacancyRates", success: function (result) { var data = new google.visualization.arrayToDataTable(result); var options = { title: 'Community Vacancy Rates', tooltip: { trigger: 'selection' }, width: 500, height: 500, is3D: true }; var chart = new google.visualization.PieChart(document.getElementById(container)); chart.setAction({ id: 'searchCommunity', text: 'View Community', action: function () { selection = chart.getSelection(); //open a search for that community window.location.href = "/Units/?community=" + data.getFormattedValue(selection[0].row, 2); } }); chart.draw(data, options); }, error: function (xhr, status, msg) { alert(msg); } }); } </code></pre> <p></p> <p>When I added the following entries into my web.config all heck broke loose.</p> <pre><code>&lt;authorization&gt;&lt;deny users="?"/&gt;&lt;/authorization&gt; </code></pre> <p><em>*</em> I also added a couple other authorization tags to allow access to anonymous users to my CSS page and related scripts and images.</p> <p>The strange thing is; the chart renders on load just fine, it is when the related action is triggered that the website crashes (in debug mode). It fails on the line </p> <pre><code>google.load(....); </code></pre> <p>"google is undefined"</p> <p>Thoughts?</p> <p><hr> <strong>Things I have tried:</strong><br> Moving the script all to "@Section Head"<br> Changing the Render to "//www.google.com/jsapi" <hr> <strong>More things, I think I'm getting closer</strong><br> (keep in mind it only fails when authentication is on)<br> If I remove the "/?community=X" from the hyperlink it all works (although I dont get the results I want on the next page obviously) In fact if I create another link on the page in the same format, with ?community the page fails outside of the google chart.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload