ksliman
ksliman

Reputation: 605

.net 6 Blazor Server app - Not working after deployment

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

enter image description here

and when I inspect the browser console I get this

enter image description here

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

Answers (3)

Mehmet Erdoğdu
Mehmet Erdoğdu

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.

enter image description here

Upvotes: 0

ksliman
ksliman

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

Jason Pan
Jason Pan

Reputation: 21972

I have tested it in my local and can't reproduce the issue. But you can follow my suggestions to troubleshoot.

enter image description here

Suggestions

  1. You also need install .net core runtime at the beginning. For more details, you can read this blog.

  2. Please make sure you can run your project with IIS Express model successfully, like below

    enter image description here

  3. 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.

  4. You can enable stdoutLogEnabled="true" to check the logs.

  5. 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

Related Questions