Skip to content

The first request to a MVC route is broken with 1.1 RC #130

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

Closed
thegyorf opened this issue May 19, 2017 · 11 comments
Closed

The first request to a MVC route is broken with 1.1 RC #130

thegyorf opened this issue May 19, 2017 · 11 comments
Assignees

Comments

@thegyorf
Copy link

Navigating to a MVC route on the first request results in the following error:

System.ArgumentException: Value cannot be null or empty.
Parameter name: viewPath
at Microsoft.AspNetCore.Mvc.ViewEngines.CompositeViewEngine.GetView(String executingFilePath, String viewPath, Boolean isMainPage)
at Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor.FindView(ActionContext actionContext, ViewResult viewResult)
at Microsoft.AspNetCore.Mvc.ViewResult.d__26.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__30.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResultExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.RouterMiddleware.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.RouterMiddleware.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Web.BrowserLink.BrowserLinkMiddleware.d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.d__7.MoveNext()

Any subsequent request to the route works just fine. API routes, Swashbuckle/Swagger integration, & the SwaggerUI page work just fine only the first request to a MVC route has a problem.

At first I thought it might have something to do with using Swashbuckle/Swagger so I made a fresh ASP.NET Core 1.1 MVC project in Visual Studio 2017, added the 1.1 RC versioning package, updated Startup.cs, and updated the Home controller to use attribute routing but the problem persists.

@commonsensesoftware
Copy link
Collaborator

Odd. Out of curiosity, how are you requesting the MVC page? Once you add API versioning, everything is versioned, even MVC UI controllers. You might consider applying [ApiVersionNeutral] to your UI controllers. Regardless, things shouldn't fail this way. I'll see what I'm able to discover.

@commonsensesoftware
Copy link
Collaborator

If you're able to share you configuration or even your entire vanilla project, that would be useful in the investigation.

@thegyorf
Copy link
Author

The controller is ApiVersionNeutral and I'm just browsing to the pages while debugging through Visual Studio.

I've uploaded the project here: https://github.com/thegyorf/IssuesRepro/tree/master/ApiVerIssue/MvcApiTest

@commonsensesoftware
Copy link
Collaborator

Did things ever work? Did you ever have the expected behavior? This might be related to the #133 regression.

@thegyorf
Copy link
Author

Yes it seems likely that #133 is related.

But no, with the RC build the MVC routes will always fail the first request and then work as expected with every subsequent request.

Reverting to the Beta2 build fixes this issue but brings back this one #106 (comment) :p

@commonsensesoftware
Copy link
Collaborator

Ok ... perfect. That's what I was looking for. I may even work some part of your repro into the acceptance tests so this regression does occur again. You'd think with all the tests I have that this type of thing couldn't slip through, but there are a lot of application configurations to try and validate. Thanks for the info.

@commonsensesoftware
Copy link
Collaborator

RC2 has been officially published. My acceptance tests now include a simple MVC view. Let me know if you run into any other issues.

@thegyorf
Copy link
Author

Updated the project in my repository to RC2 but am still getting the same first request error on the MVC routes.

@commonsensesoftware
Copy link
Collaborator

Odd. I'll pull down your full repro and investigate.

@commonsensesoftware
Copy link
Collaborator

I confirmed that this is different, but unresolved bug. There is something illusively different about a route for a view versus an API controller. Regardless, I've tracked down the issue and I'll have a fix for it shortly. In addition to expanding the acceptance tests, I also ran the changes through your repro. All seems well in the universe again. The repro was useful. Thanks.

I'll try to get RC3 out later today.

@commonsensesoftware
Copy link
Collaborator

RC3 is out and should fix this. Let me know if it doesn't. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants