Application Insights missing browser info - c#

I added Application Insights to my web project using Application Insights button in Visual Studio 2017. After that I've added JavaScript code to View\Shared\_Layout.cshtml as described here
After a week of monitoring I found that there is missing some information about client browser, OS, etc.
The following query returns only client_Type with PC value (but should also Mobile)
requests
| project client_Type, client_Browser, client_Model, client_OS
Why it is empty? What I missed? Should I add some configuration to store that info?

requests might not have browser info. that comes from the server side, so i want to say it gets everything from the UserAgent header of inbound requests.
however, the javascript code in your layout.cshtml enables PageView telemetry, which collects more information from the browser.
things to do:
1) make sure your backend (whatever is sending requests) is using the same ikey as whatever you have in your javascript snippet, to make sure you looking at the same data for both things
2) look at what's in both tables and see if it is different:
union requests, pageViews
| where timestamp > ago(14d)
| summarize count() by itemType, client_Browser
| render barchart
i bet you get a bar chart that has requests with one giant bar for one browser (empty), and a different bar for pageViews that has lots of browsers?

Related

New Server Security Causing Issues To API Response

one of my old project/app was working fine for years, very recently client report that app does not working any longer due to API response issue.
it's just a get request to an API with some parameters..
till date (before issues occurs) it returns following response:
,,3,1669179307,0,
but recently it shows following response: (note nothing is changed in the source php/code files since project start)
<html><title>You are being redirected...</title>
<noscript>Javascript is required. Please enable javascript before you are allowed to see this page.</noscript>
<script>var s={},u,c,U,r,i,l=0,a,e=eval,w=String.fromCharCode,sucuri_cloudproxy_js='',S='bT0nP2RUNCcuc3Vic3RyKDMsIDEpICsgJycgKyAKJz9iVGYnLnN1YnN0cigzLCAxKSArICcnICsgCidIcExjJy5zdWJzdHIoMywgMSkgK1N0cmluZy5mcm9tQ2hhckNvZGUoNTYpICsgJ3FAYycuY2hhckF0KDIpKyAnJyArIAonNycgKyAgICcnICsgClN0cmluZy5mcm9tQ2hhckNvZGUoMHg2MykgKyAgJycgKycnKyIyc3VjdXIiLmNoYXJBdCgwKSsiYyIgKyAiNHNlYyIuc3Vic3RyKDAsMSkgKyAiZW0iLmNoYXJBdCgwKSArICAnJyArIAoiM2MiLmNoYXJBdCgwKSArICIiICtTdHJpbmcuZnJvbUNoYXJDb2RlK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1Y3VyNCcuY2hhckF0KDUpICsgJ2YnKycyc3VjdXJpJy5jaGFyQXQoMCkgKyAiPSIgKyBtICsgJztwYXRoPS87bWF4LWFnZT04NjQwMCc7IGxvY2F0aW9uLnJlbG9hZCgpOw==';L=S.length;U=0;r='';var A='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';for(u=0;u<64;u++){s[A.charAt(u)]=u;}for(i=0;i<L;i++){c=s[S.charAt(i)];U=(U<<6)+c;l+=6;while(l>=8){((a=(U>>>(l-=8))&0xff)||(i<(L-2)))&&(r+=w(a));}}e(r);</script></html>
here is curl screenshot:
And here is the postman screenshot:
and when i check the URL in browser it shows the expected result, though when i check the devtool (network tab), it looks like page is loaded two times.. 1st one provide error (HTML/js) response (read marked) 2nd one provide the expected response (green marked), so, it looks like when it's called directly by curl/postman/c#... fails.. but as browser can do redirect it passed.
here is the browser screenshot:
i am sorry, i added several screenshot to give better idea what is happening.
and here is the URL in question:
https://simpleclienttracking.com/membershipmanager/remotelogvisit.php?locID=1&orgID=1&deptID=1&barcode=8346420
now my question, is how can i use the API code/file to get the direct response as i was getting earlier? do i need to pass any header? update/modify server htaccess file or what?
To test the error in deep, i have tried another URL from another hosting provider, in that case i am passing post request to an URL, and this server response slightly different thing, but looks like core is same, redirect!
here is the response from new/another server:
<script>document.cookie = "humans_21909=1"; document.location.reload(true)</script>
so, it's looks like hosting providers has applied some kind of security for direct URL access?
thanks in advance for any upcoming help
best regards

How to connect QuickBooks Desktop using Web Connector?

I'm trying to develop a simple webform application to create/edit invoice from a .aspx page and want to sync QB Desktop & MS SQL database using web connector & .ASMX web service (2 way sync: QBD -> web app & web app > QBD).
Here is a what I did:
I've setup QB Desktop US version 19 (latest) and Web connector
Added an application via adding .QWC file (I'm using this default .qwc file without any changes, not sure even how can I make it!!)
Step 1 & 2, are done but looking for proper solution to start with the development part. I've referred some other StackOverflow questions and found this sample but not sure which project and version I've to choose from both of them. I'm finding some good sample applications which connects to QB Desktop & Web applications using Interop.QBFC13
I really don't have idea how web connector works and sync with my web app.
Thanks!
I'm using this default .qwc file without any changes, not sure even how can I make it!!
This ^^^ will not work. Ever. There is no "default" .QWC file -- it is specific to your application and if you're using someone else's it's guaranteed not to work.
Create your own .QWC file. Example template:
<?xml version="1.0"?>
<QBWCXML>
<AppName>QuickBooks Integrator</AppName>
<AppID></AppID>
<AppURL>https://example.com/quickbooks/server.php</AppURL>
<AppDescription></AppDescription>
<AppSupport>https://example.com/quickbooks/support.php</AppSupport>
<UserName>username</UserName>
<OwnerID>{90A44FB7-33D9-4815-AC85-AC86A7E7D1EB}</OwnerID>
<FileID>{57F3B9B6-86F1-4FCC-B1FF-967DE1813D20}</FileID>
<QBType>QBFS</QBType>
<Scheduler>
<RunEveryNMinutes>2</RunEveryNMinutes>
</Scheduler>
<IsReadOnly>false</IsReadOnly>
</QBWCXML>
Fields:
<AppName> This is displayed to the user in the Web Connector GUI
<AppID></AppID> Leave it blank
<AppSupport>...</AppSupport> Must contain a valid URL to a valid page which returns a 200 OK HTTP response when visited. Users who have technical problems will be directed here.
<AppURL>...</AppURL> Must contain a valid URL to your SOAP server, https://... if it's remote, http://localhost/... if it's local.
<UserName>...</UserName> This will match the username your SOAP server understands for authentication
<FileID>...</FileID> You can make this up as long as it follows the GUID format (uppercase HEX chars only!): {6904A826-7368-11DC-8317-F7AD55D89593}. It has something to do with DataExt elements; most simple integrations can just make this up.
<OwnerID>...</OwnerID> Same as above
<QBType>...</QBType> Specifies the type of Quickbooks you want to connect to with the web connector (ie “QBFS” or “QBPOS”)
<Scheduler>...</Scheduler> This is an optional element, use this to schedule the Web Connector to run every so often automatically
<IsReadOnly>...</IsReadOnly> Leave this set to false, setting it to true will not work.
Did you read the 100+ page PDF that documents exactly how the Web Connector works and what you need to implement? Link:
QuickBooks Web Connector Programmer's Guide PDF
What have you tried to implement so far?

ASP NET Web API google authentication issue HTTP 404

I am trying to setup a social login for my site.
Here is what I did:
I created credentials on google and have both ClientID and Secret
In default MVC app, in App_Start Startup.Auth.cs I uncommented
app.UseGoogleAuthentication()* method, so it looks like this:
Build solution!
Made sure authorized JavaScript origins and Redirect url are correct. And other things that are needed on console.cloud.google.com are done. Including activation of Google+ API
Eventually Google authentication button should appear in _ExternalLoginsListPartial partial view. But as I can see I have 0 login providers still. And not sure why, and what can I do about it?
var loginProviders = Context.GetOwinContext().Authentication.GetExternalAuthenticationTypes();
//loginProviders.Count() here returns 0
Tried researching, but most are saying that you forgot to build, or restart the server. Tried that but nothing changed.
As last resort, I tried following a tutorial https://youtu.be/WsRyvWvo4EI?t=9m47s
I did everything as shown there, I should be able to reach api/Account/ExternalLogins?returnUrl=%2F&generateState=true url, and receive callback URL from Google.
But I got stuck with same HTTP404 error at 9:50
To answer my question, everything turns out to be fine.
All I had to do was just to give it some time.
After couple of hours, Google provider appeared on the page.
For future readers - if met with 404 in this case, another possibility is an active filtering rule against query strings in IIS. One of the commonly copy-pasted rules aiming to block SQL injection requests scans the query string for open (to catch OPEN cursor). Your OAuth request probably contains this word in the scopes section (data you want to pull from the Google profile)
IIS -> Request Filtering
Switch to the tab "Rules"
Inspect and remove any suspicious active filters there

How to ping a website / ip that is deployed in iis

I need to make a website that is designed to monitor / check the connectivity of our internal applications that is deployed on iis, Its like a list of links to our internal websites that we developed. The question is, how would I be able to check if a website is up and running? and how would I check if a website is down? I will simply display the links of our system and color it based on their status, green for up, and red if its down or has errors.. hoping for your advice. sample codes would be appreciated.
Just load anything from that server, if it loads your site is up and running, if it doesnt load, then just generate an error or show red
The simplest way to do this is to have a windows service or scheduled task running which performs WebRequests against the list of websites and checking the status codes.
If a status code of 200 is returned, show green. Anything else (4xx, 5xx, timeout), show red. Have the service store the results in a database and have the 'red-green' page read from that database.
That would be a generic, one-size-fits-all solution. It may not work for all sites, as some sites could have basic authentication, in which case your monitor will incorrectly record that the site is down. So you would need to store metadata against the sites and perform basic authentication (or any other business logic) to determine whether it's up or down.
If you have access to the websites you want to monitor then I would have thought the easiest way is to put a status page on the websites you want to monitor designed to be polled by your service. This way if the website is up you can get more advanced status information from it by reading the page content.
If you just want to check the http status then just access any page on the website (preferably a small one!) and check the response status code.
Something like
// prepare the web page we will be asking for
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create(Url);
//if (AuthRequired())
// request.Credentials = new NetworkCredential(Username, Password);
// execute the request
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
then you can read the response.StatusCode

How to resize Webbrowser content to fit 480 x 800

Im using some basic code to display a mobile website in my application using a web browser.
For some reason, if I use the standard browser it is sized correcly to 480 x 800 , but when I use the web browser in my application the page is way off more like 960 x 800.
Is there a way to force the size the page is displayed in the web browser?
The funny thing is that it was working a few months ago, but has suddenly gone haywire.
code is :
string site1 = "http://m.domain.com";
webBrowser1.Navigate(new Uri(site1, UriKind.Absolute));
webBrowser1.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(webBrowser1_Navigated);
I was thinking I could force user agent by using the below code, but I am getting errors " no overload for method, 'Navigate' takes 4 arguments.
webBrowser1.Navigate("http://localhost/run.php", null, null, "User-Agent: Windows Phone 7");
Page using app:
Page using standard IE9 browser outside of application, but on handset.
One place to start would be to sniff the request/response. There's clearly different HTML coming back from the server for the two requests. For the in-app browser, it clearly says it's having trouble identifying the device. If you can figure out what is different between the two requests, you might be able to force the in-app browser to make the request more like the out-of-app browser.
If you're using the simulator, Fiddler is a fantastic tool for that sort of thing. The first place I'd look is at the User-Agent header, which most sites use to figure out what type of browser is requesting the page.

Categories