Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

TestServer against MVC application can't find Razor Views. #3410

@Bartmax

Description

@Bartmax

As of right now, when you use TestServer on a Test project against an MVC application with Razor Views those are not found because ApplicationBasePath is the Test project one and not the MVC.

The solution is to change the ApplicationBasePath of the Test project to the MVC Application.

Changing the base path is not a straightforward thing to do, in terms that for every test project that needs this, one must implement IApplicationEnvironment and hook into the TestServer somehow.

I created a package at https://github.com/Bartmax/TestServerMvcHelper which hooks into WebHostingBuilder and does exactly that with one practical convention of where to look for the Application.

var builder = TestServer.CreateBuilder();
builder.UseApplicationPath("YourMvcApplication");
var server = new TestServer(builder);

I wanted to start a discussion to see if there's interest on the team for this (or similar) feature, as I think this should be provided/baked into the framework, with a maybe smarter way for application basepath discovery.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions