Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publishing Blazor to IIS from Visual Studio #21226

Closed
AndyWDev opened this issue Jan 14, 2021 · 6 comments
Closed

Publishing Blazor to IIS from Visual Studio #21226

AndyWDev opened this issue Jan 14, 2021 · 6 comments
Assignees
Labels
Blazor Source - Docs.ms Docs Customer feedback via GitHub Issue support-request

Comments

@AndyWDev
Copy link

When publishing a Blazor Server App (VS16.8.3/Net 5/EF Core) using a Visual Studio publishing profile and publishing to a local file directory, the web site fails to run giving a 500.19 internal server error (in this case, it appears to be looking for a web.config file which does not exist).

The documentation on this page is very lite with regards to publishing to IIS and I expect there is additional IIS configuration that is required to set up that environment - it would be great if this information could be documented as information found so far elsewhere appears to be out of date.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@guardrex
Copy link
Collaborator

guardrex commented Jan 14, 2021

Hello @AndyWDev ... You're almost in the right spot. See the coverage in the Overview ...

https://docs.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/?view=aspnetcore-5.0&tabs=visual-studio

... You need to point IIS to the publish folder, or you can use the contents of that folder for your site folder for IIS. You will find a web.config file there.

WRT improving this coverage ... Yes! I will. I'm working though all of the Blazor topics in the first half of this year. When I reach this node of topics, I will make improvements. To make sure that I don't lose your comment here, I've noted it on my tracking issue at #19286.

@AndyWDev
Copy link
Author

Hi,
Thanks for your reply.

I did find the web.config as per your post and IIS was already pointing to this directory. I also set the app-pool to not use managed code. I was still getting the error.

Next, I installed the IIS core (2.2 I think) for IIS, and then re-installed the .Net 5 SDK again in case my one too old. I can now run the app in IIS, although for some reason my default page does not load (I get MainLayout and the Nav showing, but not my default content page - it does work when F5 debugging using IIS Express).

These are the things I meant by additional configuration. I know they are mentioned in different places already, just not in one single place. :)

@guardrex
Copy link
Collaborator

You did the right thing with a re-install of the hosting bundle and restart of IIS. You may have had an old ASP.NET Core Module that doesn't work well with the latest release.

WRT the default page not loading, I don't know why that would happen. I've never had that happen here. You can ask for help on the usual support channels. We recommend ...

If you still can't figure out the problem, you can open a bug report with the product unit. It's best in this case to put up a repro project on GH and show them screenshots of your folder setup and IIS basic+binding configuration with a screenshot of the Index.razor page not loading. You would open that issue at
https://github.com/dotnet/aspnetcore/issues. I do recommend tho that you try to troubleshoot on your own first with the help of the community. They're crazy busy over there.

I'll work on the topics in this node when I reach them on the tracking issue. I'll review your remarks at that time.

@guardrex
Copy link
Collaborator

... one more note on ...

I know they are mentioned in different places already, just not in one single place. :)

Yes, Blazor docs will not go that far. You will need to access the IIS docs for general config. I think you know already where they are, but here's the link to that section of docs if you didn't see them ...

https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-5.0

What's in the Blazor docs Host and deploy node cover the concepts that apply specifically to Blazor.

@AndyWDev
Copy link
Author

Update: the not loading the default page was due to the application pool identity account not being set causing the DB connection to fail.

There isn't a bug as such - there isn't enough [up-to-date] information documented (in one place) such that one can publish a Blazor app to IIS. The issues that I encountered are symptomatic of this.

@guardrex
Copy link
Collaborator

I understand, but I don't think we'll be going that way with the reference coverage. We don't want to duplicate the ASP.NET Core Host and deploy coverage in the Blazor topics. However, a tutorial for this scenario is worth considering. We have one for a garden variety ASP.NET Core app at ...

https://docs.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-5.0&tabs=visual-studio

... so I'll consider creating one like that for Blazor WASM or possibly make that tutorial cover Blazor apps. There's very little difference for Blazor apps. Once IIS is pointed to the right folder/web.config and the little bit of additional content is consumed and addressed, a Blazor app should run fine under IIS following the general ASP.NET Core guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blazor Source - Docs.ms Docs Customer feedback via GitHub Issue support-request
Projects
Archived in project
Development

No branches or pull requests

4 participants