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

RazorPages page directives missing quotes should alert user #5868

Closed
ryanbrandenburg opened this issue Feb 28, 2017 · 14 comments
Closed

RazorPages page directives missing quotes should alert user #5868

ryanbrandenburg opened this issue Feb 28, 2017 · 14 comments

Comments

@ryanbrandenburg
Copy link
Contributor

ryanbrandenburg commented Feb 28, 2017

Edit: Reopening after some discussion.

The issue here is that if we can't parse the route we can't assign what the user 'expects' the route to be to the page. So if the user can't visit the page because it doesn't get the URL that they expect, then how will they know that it's invalid?


Original

As per #5838 (comment) we should have a think about how we handle the case of @page Url/Here. Right now we ignore the URL because it's not in quotes, but there's some concern that that will confuse the users and that we should either throw an exception or at least log a message.

@rynowak
Copy link
Member

rynowak commented Mar 3, 2017

This should be a parsing error coming from Razor.

@rynowak
Copy link
Member

rynowak commented Mar 3, 2017

aspnet/Razor#980 is the proper issue for this.

@rynowak rynowak closed this as completed Mar 3, 2017
@rynowak rynowak reopened this Mar 3, 2017
@Eilon
Copy link
Member

Eilon commented Mar 13, 2017

There are three distinct cases to consider:

  1. Directive isn't even formatted correctly.
    • The page will get its default route (based on its file path), and when you run it you see a parser error.
  2. Directive is formatted correctly, but route within it is not a valid route.
    • The startup will fail when the invalid route is being added to the system.
  3. Directive is formatted correctly, route is also formatted correctly, but it's not what you meant.
    • No errors will happen anywhere. (We could consider in the future to have some route table / route debugger feature as part of diagnostics)

The work for this item is:

  • For cases (1) and (2), log as Warning the problem
  • Add tests that confirm all the above behavior (and if not, fix as needed)

@ryanbrandenburg
Copy link
Contributor Author

(1) already logs and has a test here. Do we want a functional test for it in MVC as well or is that enough?

(2) When you say not a valid route how do you mean? Do you just mean something like @page "Broken?" with a banned character in it, or do you mean it would route to something that's already covered by another page/controller?

It doesn't sound like you want anything done for (3), but for posterity how would we know if it's "not what you meant".

@rynowak
Copy link
Member

rynowak commented May 19, 2017

  1. How is this logging? It's a compilation error which you will never see because you don't actually visit the page

  2. Yes, we mean a totally invalid route.

  3. Yeah, we're saying there's no action to take here.

@rynowak rynowak modified the milestones: 2.0.0-preview3, 2.0.0-preview2 May 24, 2017
@pranavkm
Copy link
Contributor

pranavkm commented Jun 6, 2017

@ajaybhargavb \ @NTaylorMullen, doesn't the directive parser already validate this?

@Eilon
Copy link
Member

Eilon commented Jun 6, 2017

At the very least we need to make sure we have tests for all the scenarios listed here: #5868 (comment)

@NTaylorMullen
Copy link
Contributor

@pranavkm It sees the problem but it doesn't log the issue anywhere. Essentially the error goes nowhere.

@rynowak
Copy link
Member

rynowak commented Jun 6, 2017

For cases (1) and (2), log as Warning the problem

This means ILogger not a diagnostic from Razor.

@pranavkm
Copy link
Contributor

pranavkm commented Jun 6, 2017

@rynowak - would Razor depend on Logging or would we add diagnostics with error levels and print them from Mvc?

@rynowak
Copy link
Member

rynowak commented Jun 6, 2017

Razor depend on Logging

Razor will not depend on logging.

would we add diagnostics with error levels and print them from Mvc?

I'm not convinced that what we're discussing here is complicated. If it is complicated, then we can probably punt this or close it.

@Eilon
Copy link
Member

Eilon commented Jun 7, 2017

@rynowak - if Razor doesn't depend on logging, how does the "log" flow to the user's ILoggerFactory?

@rynowak
Copy link
Member

rynowak commented Jun 7, 2017

It comes from Microsoft.AspNetCore.Mvc.RazorPages.

@Eilon
Copy link
Member

Eilon commented Jun 7, 2017

Ah ok.

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

No branches or pull requests

6 participants