Swagger UI Not Loading Sometimes - google-chrome

I'm using latest version of Swagger in my ASPNetCore 3.1 project and debugging on latest version of Chrome. When I try to enter swagger page it sometimes not loading and i see an empty page. It looks like totally random. It solves after I refresh the page.
I saw these errors on console.
GET https://localhost:44389/swagger/swagger-ui-bundle.js net::ERR_HTTP2_PROTOCOL_ERROR
index.html:95 Uncaught ReferenceError: SwaggerUIBundle is not defined
at window.onload (index.html:95)
File in the error is random. Its sometimes a js file, sometimes a .css file. It changes.
If I publish this project on IIS and disable Http/2 support I never encounter this error.
Why?

You can try the following:
1.Check if all your controller methods have [http] tag. If they all do and still doesn't work go to step 2
2.In your configure function to ensure that you have app.UseStaticFiles(); If it still doesn't work go to step 3
3.Uninstall and reinstall swagger. If it doesn't work go to step 4 (Core Only)
4.If you are using Core Install Microsoft.AspNetCore.StaticFiles and reference it in your project.

I encountered the same problem, SwaggerUIBundle is not defined, and the problem is not on the web app that I'm developing but on my network. The problem was resolved after I switch to another network.

Related

NTLM authentication doesn't work for JS files unless Fiddler is running

I am running an ASP.NET 4 app in IIS using NTLM (Windows) Authentication. All other authentication schemes are disabled. I am able to authenticate to the server successfully. However, even after successfully authenticating, the server (under certain circumstances explained below) still returns a 401 Unauthorized error when I request Javascript files. Why am I unauthorized to download JS files?
Granted, I don't completely understand how NTLM works, but I expect something like the following to happen when I request a protected resource:
I make a request to localhost:444 (yes, this is the correct port)
I am not authenticated, so IIS returns a 401 to my web browser.
My web browser understands that it must provide me with a popup in which to enter my username and password. I do so.
The browser and IIS perform the NTLM auth flow. (tbh, I don't know the details of this.) Authentication is successful. The browser understands to re-request my original request from Step 1.
IIS returns index.html.
Index.html references a CSS file and some JS files. The browser requests these files.
IIS returns these files.
This desired functionality is working... usually. When I'm accessing the site from Firefox, or Chrome 78, or Chrome 83, everything works as expected. However, when I access the site using Chrome 70, the following happens instead:
Steps 1 thru 5 work correctly as explained above.
Index.html references a CSS file and some JS files. The browser requests these files.
IIS returns the CSS file, but returns a 401 error for the JS file.
Then however, when I turned on Fiddler (and configured it to decrypt https, because I've been using https) Chrome 70 started behaving correctly, just like Firefox and Chrome 78 and Chrome 83 are. I turned Fiddler off again, and I got the same error (on my JS file) again.
Does anyone have any idea what the issue is?
Thanks!
The issue was not with the authentication; the authentication was working correctly.
The issue was with Angular 8/9 and Chome 70. I happened across this post which helped me discover this forum thread which (sortof) explains the issue.
Turns out, Angular 8 changed the way the the index.html formats its script tag. In Angular 8+, the tag makes use of JS modules and such, and includes a fall-back for browsers that don't support JS modules. However, Chrome 70 (and possibly others) seems to support JS modules poorly (I don't understand the exact nuances of what Chrome 70 does and doesn't do). Therefore, instead of using the fall-back for browsers that don't support JS modules, Chrome 70 seems to have made a malformed request for the JS files. Specifically, Chrome 70 requested the JS files, but requested their MIME type to be "text/plain" instead of "text/javascript". When IIS received this (assumedly) malformed request, it returned a 401 error. (I would've thought it would return a 400 error, but whatever.)
I don't know why turning on Fiddler fixed the issue. Maybe Fiddler was somehow changing the (assumedly) malformed headers to be correct again? I don't know.
The solution is easy - in your tsconfig.json file, simply set the target to "es5" instead of "es2015" (or whatever else is the default in the future). Compiling to es5 simply doesn't use the features that confuse Chrome 70.

Getting exception "Unknown Error" after bundling the application(exe)

We are using the evaluation version of JXBrowser for some charting application. We wanted to showcase a demo to our client just to check the overall performance of charts with JXBrowser. But we encountered some unexpected issue while we were trying to build an "EXE".
The issue:
We created a build and the passed the URL from the classpath(webView.getBrowser().loadURL(getClass().getResource("/chartiq/stx-advanced.html").toExternalForm());); the build successfully generated and if we run the build we are getting exception "Unknown Error" but its working fine in the IDE(Eclipse).
Afterwards, we tried to host the html pages at some server and we were able to get the html rendered in the application.
Question:
1. Is the aforementioned issue related to evaluation version?
2. If above question is not the case, is there any fix for that? As we have crawled the web and find nothing related to this.
For the reference I attached the screen shot showing the full exception stacktrace.
Any help will be appreciated.
Thanks,
Nikhil
The reason of this issue is that JxBrowser doesn't support loading resources from JAR files. Chromium engine used in JxBrowser cannot load the /chartiq/stx-advanced.html file located inside JAR archive. You need to extract the file and load the extracted file.
FYI: we have already started working on the functionality that allows loading HTML files and other resources from JAR archives. An updated build with this functionality will be available in December.

Visual Studio Code (vscode) - Request textDocument/documentLink failed error on key press

Hi I'm running VSCode on my mac and Windows 10 machine. They've both started displaying the same symptoms after the latest update/rollback.
Every couple of keypresses I get the output box appear, with the "HTML Language Server" selected in the dropdown. The error displayed is:
[Error - 13:47:09] Request textDocument/documentLink failed.
Message: Request textDocument/documentLink failed with message: Path must be a string. Received undefined
Code: -32603
This gets repeated indefinetly and is making VSCode unusable. I'm editing some JSP / JSTL files so I'm wondering if it's some non-valid HTML setting it off, but this has never been an issue before.
All research I've found of this error seems to suggest a faulty extension, but I've currently not got any installed.
Help appreciated!
This is a known issue and, as per this Github issue, the workaround is to open Visual Studio Code on a folder instead of a file.
I too had this popping up this morning, google pointed me to vscode's extensions, so I went through the vscode extensions, updated them all and Debugger for Chrome (2.2.0) was the only one fitting the Error message.
Since I do not have the time right now to file an issue (and answer follow-ups) on https://github.com/Microsoft/vscode-chrome-debug/issues I have just disabled the extension for now.
One thing to note is, while vscode says it is version 2.2.2 in the extension panel, it is 2.2.0 on its marketplace page and github. Might be of some interest to dive in and find out where the extension panel picks up its - false - version number - and find out whether this has some impact on creating the error.

GWT Super dev mode stopped working under Chrome, no request for source maps

I'm using GWT 2.7.0 with GXT 3.1.1 and IntelliJ 15.0.5 and Chrome 50. I debug my application using the Super Dev Mode (with a separate code server and bookmarklets) and up to now it's worked quite well.
However, for no apparent reason, today the Super Dev Mode has stopped working under Chrome (I can get it to work under IE 11). Everything works as before, but my *.java files are no longer visible in the Chrome Dev Tools.
I've been doing clean-and-rebuild (including cleaning gwt-unitCache), checking SO posts, reconfiguring SDM in IntelliJ, but so far nothing's helped.
Here's what I've managed to find out (inspired but this post):
Source maps are enabled
I can see source maps on gwtproject.org
In Chrome's Network tab I can see 2 requests for *.nocache.js (one to my server, the other to the code server). Neither of these requests has the X-SourceMap response header
There is NO request for gwtSourceMap.json
There is nothing interesting in the Super Dev Mode logs, this is the only reference to anything source-map-related:
Linking per-type JS with 5560 new types.
prelink JS size = 11286518
prelink sourcemap = 11286518 bytes and 260145 lines
postlink JS size = 10968640
postlink sourcemap = 10968640 bytes and 253152 lines
Source Maps Enabled
Compile of permutations succeeded
Compilation succeeded -- 34,546s
I have a separate module file for Super Dev Mode with just 1 permutation:
<set-property name="gxt.user.agent" value="chrome"/>
<set-property-fallback name="user.agent" value="safari"/>
I'm starting to run out of ideas (other than going through gwt sources), any help would be really appreciated.
I had a problem today with similar symptoms.
Eventually found that in chrome dev tool, i'd blacklisted an important gwt js file (project-0.js). I just didn't want to see it in tracebacks when i was debugging some native js stuff, but with that blacklisted, the sourcemaps weren't getting pulled in! Once I un-blacklisted it, I could once again load and debug gwt java in cdt.

Chrome HTTP2.0 throws SPDY PROTOCOL ERROR

I'm using Windows 10 Technical preview. I know it's not yet tweeked out to full usage, but here is my problem.
On local IIS I'm developing my web app. It loads most of the data via ASP.NET MVC API. After the upgrade to Windows 10 I started to get
net::ERR_SPDY_PROTOCOL_ERROR
for all AJAX calls to API. The HTML page loads normally, but the dynamic loading of data content fails. I managed to figure it out by starting Chrome with parameters
--use-spdy=off --use-system-ssl
Strange thing is that on the first start I always get this error and have to restart Chrome. Other browsers fail too, but not with specific error. For the transfer there is used HTTP2.0 protocol, which is based on SPDY protocol.
Do I have to turn something off in IIS?
Edit:
Seems like an IIS problem with HTTP2.0. When trying to enter the site from Windows 8.1 I get the same error.
Most people’s reaction to this error would be to reload the web page. We would actually recommend this as a first response. Sometimes this even does work.
Interesting Factoid: SPDY actually stands for “speedy” and is used to reduce a web pages’ load time
If reloading the web pages does not remove the error, then you should close down Google Chrome and restart it. This alone will not really solve the problem because you will need to clear the cache as soon as you restart the browser.
or in cmd clear dns using this command ipconfig/flushdns