1

I have created a simple Blazor Server app with VS2022. I just used the default example code and made no changes. The application is then run on my server, where I can access it via https://myserver/myapp (a IIS redirect redirects that to http://localhost:5000).

The problem now is that the app cannot find any of the CSS files. E.g. it tries to load "https://myserver/css/site.css", which does not exist. The correct path would be "https://myserver/myapp/css/site.css".

How can I change the path where the Blazor app looks for its files?

1
  • What is your project structure? Try putting your css file under myserver. Commented Apr 19, 2022 at 9:14

1 Answer 1

3

The correct path would be "https://myserver/myapp/css/site.css".

When you had installed it as a regular IIS WebSite then it would have worked 'out of the box'. But with a IIS redirect things could fall apart.

Your best option now is to change the base href in _Layout.cshtml to

<base href="~/myapp/" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.