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

Routing for View Pages #5353

Closed
pranavkm opened this issue Oct 3, 2016 · 5 comments
Closed

Routing for View Pages #5353

pranavkm opened this issue Oct 3, 2016 · 5 comments

Comments

@pranavkm
Copy link
Contributor

pranavkm commented Oct 3, 2016

Routing

By default, the route for each page is mapped at it's application relative path (with the cshtml extension). The file name Index is optional and has the same behavior as routing to an action named Index in conventional routing i.e.
/Home/Index and /Home are equivalent. The optional value of the@page directive can be used to append a suffix to this route. Consider,

Page Directive Routes
/About.cshtml @page http://myappdomain.net/About
/Contact.cshtml @page "location/{zip}" http://myappdomain.net/Contact/location/98052
/Catalog/Index.cshtml @page http://myappdomain.net/Catalog http://myappdomain.net/Catalog/Index
/Catalog/Books.cshtml @page "{id?}" http://myappdomain.net/Catalog/Books/ http://myappdomain.net/Catalog/Books/12

Friendly urls

Associated with each page is an application model type similar to ControllerModel. We'd build on top of this to provide simple runtime configuration of routes. For instance, to configure an additional route to the /Catalog/Books.cshtml, here's what the Startup code might look like:

services
    .AddMvc()
    .AddRazorPages(options =>
    {
        options.MapPageRoute("Books/{id?}", "/Catalog/Books.cshtml");
    });
@pranavkm
Copy link
Contributor Author

pranavkm commented Oct 3, 2016

cc @DamianEdwards \ @rynowak

@pranavkm pranavkm changed the title Routing for Razor Pages Routing for View Pages Oct 3, 2016
@danroth27 danroth27 modified the milestone: 1.2.0 Oct 5, 2016
pranavkm added a commit that referenced this issue Nov 17, 2016
pranavkm added a commit that referenced this issue Nov 18, 2016
pranavkm added a commit that referenced this issue Nov 21, 2016
@mikebrind
Copy link

@pranavkm The MapPageRoute method doesn't exist on RazorPageOptions in Preview 1.0. Has this configuration option been moved somewhere else? Not included at all? If not, are there still plans to include it?

@pranavkm
Copy link
Contributor Author

@mikebrind - doesn't look like I did any of the work for making friendly urls work - must've missed it. @rynowak - are we still on for adding a convention extension to register additional routes?

@pranavkm
Copy link
Contributor Author

Also cc @DamianEdwards

@DamianEdwards
Copy link
Member

Oops. This is meant to be there. Can we create a new issue to track this work and triage it into the next milestone please? We're out of time to do it in this one.

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

5 participants