dotnet / dotnet/aspnetcore

Using Startup class not from the execution Assembly

Open
#7,315 16 comments 12 reactions 0 assignees View on GitHub
affected-medium area-hosting area-networking enhancement severity-minor
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

### Describe the bug
Hey,

I am trying to use a Startup class like that
`WebHost.CreateDefaultBuilder(args).UseStartup().Build().Run()`
When the Startup class is located in the execution assembly everything works fine.
When the Startup class is located in a different assembly, the service runs but things go wrong during requests - the service throws a 404 without any explanation.

Why is it important for me to put my Startup class in a different assembly?
Because I have many services that are using the exact same Startup configuration and I want to prevent duplication.

### To Reproduce
Steps to reproduce the behavior:
1. Creating new template of Asp.net core 2.2 WebApi
2. Request is working
3. Creating new Project of .Net Standard 2.0
4. Moved the Startup class from the Asp.net Core project to the .Net Standard Project
5. Added these two nugets to the .Net Standard project : 'Microsoft.AspNetCore.Mvc' and 'Microsoft.AspNetCore.Diagnostics' Nugets.
6. Add Reference from the Asp.net core project the .Net Standard project
7. Request is not working

Thank you :)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.