Reputation: 605
This is driving me crazy , I have an app that works local but when deployed to windows server 2019 I get the error that say
and when I inspect the browser console I get this
I get no errors in the windows event logs , I have installed .net 6 hosting bundle, when run the console app alone it does not have any errors.
Has anyone came across this?
Upvotes: 1
Views: 2074
Reputation: 510
I was having a problem with this topic as well. You may also have the following situation as a similar issue.
It turned out that the problem was nothing to do with my code, nor my site settings on the server. I use Cloudflare, and had set it to minify HTML. This removes the two HTML comments that are essential for Blazor to work. See this article for more information.
So, if you are using Cloudflare, by all means set it to minify JavaScript and CSS, but DO not minify HTML.
Upvotes: 0
Reputation: 605
So this ended up being an access issue. For whatever reason the exception was not being logged, and since the response was coming back as HTML it explains the "unexpected token" error in the browser console.
So far , I really love blazor , but debugging is a little cumbersome.
Upvotes: 0
Reputation: 21972
I have tested it in my local and can't reproduce the issue. But you can follow my suggestions to troubleshoot.
Suggestions
You also need install .net core runtime at the beginning. For more details, you can read this blog.
Please make sure you can run your project with IIS Express model successfully, like below
After the steps you have tried, if you still facing some issue, please try to re-publish the project, make sure the content is latest.
You can enable stdoutLogEnabled="true"
to check the logs.
If you have free trial in azure, you can try to deploy it, and if it can run normally, that mean your server has some issue or wrong settings.
Upvotes: 1