RouteCollection.MapPageRoute RouteCollection.MapPageRoute RouteCollection.MapPageRoute RouteCollection.MapPageRoute Method

Definición

Permite definir rutas para las aplicaciones de formularios Web Forms.Provides a way to define routes for Web Forms applications.

Sobrecargas

MapPageRoute(String, String, String) MapPageRoute(String, String, String) MapPageRoute(String, String, String) MapPageRoute(String, String, String)

Permite definir rutas para las aplicaciones de formularios Web Forms.Provides a way to define routes for Web Forms applications.

MapPageRoute(String, String, String, Boolean) MapPageRoute(String, String, String, Boolean) MapPageRoute(String, String, String, Boolean) MapPageRoute(String, String, String, Boolean)

Permite definir rutas para las aplicaciones de formularios Web Forms.Provides a way to define routes for Web Forms applications.

MapPageRoute(String, String, String, Boolean, RouteValueDictionary) MapPageRoute(String, String, String, Boolean, RouteValueDictionary) MapPageRoute(String, String, String, Boolean, RouteValueDictionary) MapPageRoute(String, String, String, Boolean, RouteValueDictionary)

Permite definir rutas para las aplicaciones de formularios Web Forms.Provides a way to define routes for Web Forms applications.

MapPageRoute(String, String, String, Boolean, RouteValueDictionary, RouteValueDictionary) MapPageRoute(String, String, String, Boolean, RouteValueDictionary, RouteValueDictionary) MapPageRoute(String, String, String, Boolean, RouteValueDictionary, RouteValueDictionary) MapPageRoute(String, String, String, Boolean, RouteValueDictionary, RouteValueDictionary)

Permite definir rutas para las aplicaciones de formularios Web Forms.Provides a way to define routes for Web Forms applications.

MapPageRoute(String, String, String, Boolean, RouteValueDictionary, RouteValueDictionary, RouteValueDictionary) MapPageRoute(String, String, String, Boolean, RouteValueDictionary, RouteValueDictionary, RouteValueDictionary) MapPageRoute(String, String, String, Boolean, RouteValueDictionary, RouteValueDictionary, RouteValueDictionary) MapPageRoute(String, String, String, Boolean, RouteValueDictionary, RouteValueDictionary, RouteValueDictionary)

Permite definir rutas para las aplicaciones de formularios Web Forms.Provides a way to define routes for Web Forms applications.

Ejemplos

El ejemplo siguiente muestra cómo definir rutas para una aplicación de formularios Web Forms mediante el uso de este método.The following example shows how to define routes for a Web Forms application by using this method. El ejemplo muestra un método denominado RegisterRoutes que se llama desde Application_Start en el archivo Global.asax.The example shows a method named RegisterRoutes that is called from Application_Start in the Global.asax file. El método usa cada sobrecarga de MapPageRoute para agregar una ruta a la aplicación.The method uses each overload of MapPageRoute to add a route to the application. Para obtener más información acerca de cómo definir rutas para las aplicaciones de formularios Web Forms, vea Cómo: Definir rutas para las aplicaciones de formularios Web.For more information about how to define routes for Web Forms applications, see How to: Define Routes for Web Forms Applications.

 void RegisterRoutes(RouteCollection routes)
{
    routes.MapPageRoute("",
        "SalesReport/{locale}/{year}/{*queryvalues}", "~/sales.aspx");

    routes.MapPageRoute("SalesSummaryRoute",
        "SalesReportSummary/{locale}", "~/sales.aspx");

    routes.MapPageRoute("SalesDetailRoute",
        "SalesReportDetail/{locale}/{year}/{*queryvalues}", "~/sales.aspx",
        false);

    routes.MapPageRoute("SalesCurrentYearRoute",
        "SalesReportCurrent/{locale}/{year}/{*queryvalues}", "~/sales.aspx",
        false,
        new RouteValueDictionary 
            { { "locale", "US" }, { "year", DateTime.Now.Year.ToString() } });

    routes.MapPageRoute("ExpenseCurrentYearRoute",
        "ExpenseReportCurrent/{locale}", "~/expenses.aspx",
        false,
        new RouteValueDictionary 
            { { "locale", "US" }, { "year", DateTime.Now.Year.ToString() } },
        new RouteValueDictionary 
            { { "locale", "[a-z]{2}" }, { "year", @"\d{4}" } });

    routes.MapPageRoute("ExpenseDetailRoute",
        "ExpenseReportDetail/{locale}/{year}/{*queryvalues}", "~/expenses.aspx",
        false,
        new RouteValueDictionary 
            { { "locale", "US" }, { "year", DateTime.Now.Year.ToString() } },
        new RouteValueDictionary 
            { { "locale", "[a-z]{2}" }, { "year", @"\d{4}" } },
        new RouteValueDictionary 
            { { "account", "1234" }, { "subaccount", "5678" } });
}
Sub RegisterRoutes(ByVal routes As RouteCollection)
    routes.MapPageRoute("",
        "SalesReport/{locale}/{year}/{*queryvalues}", "~/sales.aspx")

    routes.MapPageRoute("SalesSummaryRoute",
        "SalesReportSummary/{locale}", "~/sales.aspx")

    routes.MapPageRoute("SalesDetailRoute",
        "SalesReportDetail/{locale}/{year}/{*queryvalues}", "~/sales.aspx",
        False)

    routes.MapPageRoute("SalesCurrentYearRoute",
        "SalesReportCurrent/{locale}/{year}/{*queryvalues}", "~/sales.aspx",
        false,
        new RouteValueDictionary(New With _ 
            { .locale = "US", .year = DateTime.Now.Year.ToString()}))

    routes.MapPageRoute("ExpenseCurrentYearRoute",
        "ExpenseReportCurrent/{locale}", "~/expenses.aspx",
        false,
        new RouteValueDictionary(New With _
            { .locale = "US", .year = DateTime.Now.Year.ToString()}),
        new RouteValueDictionary(New With _
            { .locale = "[a-z]{2}", .year = "\d{4}" }))

    routes.MapPageRoute("ExpenseDetailRoute",
        "ExpenseReportDetail/{locale}/{year}/{*queryvalues}", "~/expenses.aspx",
        false,
        new RouteValueDictionary(New With _
            { .locale = "US", .year = DateTime.Now.Year.ToString()}),
        new RouteValueDictionary(New With _ 
            { .locale = "[a-z]{2}", .year = "\d{4}" }),
        new RouteValueDictionary(New With _
            { .account = "1234", .subaccount = "5678" }))
End Sub

Comentarios

Este método se proporciona para mayor comodidad de codificación.This method is provided for coding convenience. Equivale a llamar a la Add método y pasando un Route objeto que se crea mediante la PageRouteHandler clase.It is equivalent to calling the Add method and passing a Route object that is created by using the PageRouteHandler class.

MapPageRoute(String, String, String) MapPageRoute(String, String, String) MapPageRoute(String, String, String) MapPageRoute(String, String, String)

Permite definir rutas para las aplicaciones de formularios Web Forms.Provides a way to define routes for Web Forms applications.

public:
 System::Web::Routing::Route ^ MapPageRoute(System::String ^ routeName, System::String ^ routeUrl, System::String ^ physicalFile);
public System.Web.Routing.Route MapPageRoute (string routeName, string routeUrl, string physicalFile);
member this.MapPageRoute : string * string * string -> System.Web.Routing.Route
Public Function MapPageRoute (routeName As String, routeUrl As String, physicalFile As String) As Route

Parámetros

routeName
String String String String

El nombre de la ruta.The name of the route.

routeUrl
String String String String

Modelo de dirección URL de la ruta.The URL pattern for the route.

physicalFile
String String String String

Dirección URL física de la ruta.The physical URL for the route.

Devoluciones

Ruta que se agrega a la colección de rutas.The route that is added to the route collection.

Ejemplos

El ejemplo siguiente muestra cómo definir una ruta mediante este método.The following example shows how to define a route by using this method. La primera instrucción define una ruta que no tiene un nombre.The first statement defines a route that does not have a name. La segunda instrucción define una ruta con nombre.The second statement defines a named route. Este ejemplo forma parte de un ejemplo más extenso que está disponible en el MapPageRoute información general del método.This example is part of a larger example that is available in the MapPageRoute method overview.

routes.MapPageRoute("",
    "SalesReport/{locale}/{year}/{*queryvalues}", "~/sales.aspx");

routes.MapPageRoute("SalesSummaryRoute",
    "SalesReportSummary/{locale}", "~/sales.aspx");
routes.MapPageRoute("",
    "SalesReport/{locale}/{year}/{*queryvalues}", "~/sales.aspx")

routes.MapPageRoute("SalesSummaryRoute",
    "SalesReportSummary/{locale}", "~/sales.aspx")

Comentarios

Este método se proporciona para mayor comodidad de codificación.This method is provided for coding convenience. Equivale a llamar a la Add método y pasando un Route objeto que se crea mediante la PageRouteHandler clase.It is equivalent to calling the Add method and passing a Route object that is created by using the PageRouteHandler class.

Consulte también:

MapPageRoute(String, String, String, Boolean) MapPageRoute(String, String, String, Boolean) MapPageRoute(String, String, String, Boolean) MapPageRoute(String, String, String, Boolean)

Permite definir rutas para las aplicaciones de formularios Web Forms.Provides a way to define routes for Web Forms applications.

public:
 System::Web::Routing::Route ^ MapPageRoute(System::String ^ routeName, System::String ^ routeUrl, System::String ^ physicalFile, bool checkPhysicalUrlAccess);
public System.Web.Routing.Route MapPageRoute (string routeName, string routeUrl, string physicalFile, bool checkPhysicalUrlAccess);
member this.MapPageRoute : string * string * string * bool -> System.Web.Routing.Route
Public Function MapPageRoute (routeName As String, routeUrl As String, physicalFile As String, checkPhysicalUrlAccess As Boolean) As Route

Parámetros

routeName
String String String String

El nombre de la ruta.The name of the route.

routeUrl
String String String String

Modelo de dirección URL de la ruta.The URL pattern for the route.

physicalFile
String String String String

Dirección URL física de la ruta.The physical URL for the route.

checkPhysicalUrlAccess
Boolean Boolean Boolean Boolean

Valor que indica si ASP.NET debe validar que el usuario está autorizado para obtener acceso a la dirección URL física (siempre se comprueba la dirección URL de la ruta).A value that indicates whether ASP.NET should validate that the user has authority to access the physical URL (the route URL is always checked). Este parámetro establece la propiedad CheckPhysicalUrlAccess.This parameter sets the CheckPhysicalUrlAccess property.

Devoluciones

Ruta que se agrega a la colección de rutas.The route that is added to the route collection.

Ejemplos

El ejemplo siguiente muestra cómo definir una ruta mediante este método.The following example shows how to define a route by using this method. Este ejemplo forma parte de un ejemplo más extenso que está disponible en el MapPageRoute información general del método.This example is part of a larger example that is available in the MapPageRoute method overview.

routes.MapPageRoute("SalesDetailRoute",
    "SalesReportDetail/{locale}/{year}/{*queryvalues}", "~/sales.aspx",
    false);
routes.MapPageRoute("SalesDetailRoute",
    "SalesReportDetail/{locale}/{year}/{*queryvalues}", "~/sales.aspx",
    False)

Comentarios

Este método se proporciona para mayor comodidad de codificación.This method is provided for coding convenience. Equivale a llamar a la Add método y pasando un Route objeto que se crea mediante la PageRouteHandler clase.It is equivalent to calling the Add method and passing a Route object that is created by using the PageRouteHandler class.

Consulte también:

MapPageRoute(String, String, String, Boolean, RouteValueDictionary) MapPageRoute(String, String, String, Boolean, RouteValueDictionary) MapPageRoute(String, String, String, Boolean, RouteValueDictionary) MapPageRoute(String, String, String, Boolean, RouteValueDictionary)

Permite definir rutas para las aplicaciones de formularios Web Forms.Provides a way to define routes for Web Forms applications.

public:
 System::Web::Routing::Route ^ MapPageRoute(System::String ^ routeName, System::String ^ routeUrl, System::String ^ physicalFile, bool checkPhysicalUrlAccess, System::Web::Routing::RouteValueDictionary ^ defaults);
public System.Web.Routing.Route MapPageRoute (string routeName, string routeUrl, string physicalFile, bool checkPhysicalUrlAccess, System.Web.Routing.RouteValueDictionary defaults);
member this.MapPageRoute : string * string * string * bool * System.Web.Routing.RouteValueDictionary -> System.Web.Routing.Route
Public Function MapPageRoute (routeName As String, routeUrl As String, physicalFile As String, checkPhysicalUrlAccess As Boolean, defaults As RouteValueDictionary) As Route

Parámetros

routeName
String String String String

El nombre de la ruta.The name of the route.

routeUrl
String String String String

Modelo de dirección URL de la ruta.The URL pattern for the route.

physicalFile
String String String String

Dirección URL física de la ruta.The physical URL for the route.

checkPhysicalUrlAccess
Boolean Boolean Boolean Boolean

Valor que indica si ASP.NET debe validar que el usuario está autorizado para obtener acceso a la dirección URL física (siempre se comprueba la dirección URL de la ruta).A value that indicates whether ASP.NET should validate that the user has authority to access the physical URL (the route URL is always checked). Este parámetro establece la propiedad CheckPhysicalUrlAccess.This parameter sets the CheckPhysicalUrlAccess property.

defaults
RouteValueDictionary RouteValueDictionary RouteValueDictionary RouteValueDictionary

Valores predeterminados de los parámetros de la ruta.Default values for the route parameters.

Devoluciones

Ruta que se agrega a la colección de rutas.The route that is added to the route collection.

Ejemplos

El ejemplo siguiente muestra cómo definir una ruta mediante este método.The following example shows how to define a route by using this method. Este ejemplo forma parte de un ejemplo más extenso que está disponible en el MapPageRoute información general del método.This example is part of a larger example that is available in the MapPageRoute method overview.

routes.MapPageRoute("SalesCurrentYearRoute",
    "SalesReportCurrent/{locale}/{year}/{*queryvalues}", "~/sales.aspx",
    false,
    new RouteValueDictionary 
        { { "locale", "US" }, { "year", DateTime.Now.Year.ToString() } });
routes.MapPageRoute("SalesCurrentYearRoute",
    "SalesReportCurrent/{locale}/{year}/{*queryvalues}", "~/sales.aspx",
    false,
    new RouteValueDictionary(New With _ 
        { .locale = "US", .year = DateTime.Now.Year.ToString()}))

Comentarios

Este método se proporciona para mayor comodidad de codificación.This method is provided for coding convenience. Equivale a llamar a la Add método y pasando un Route objeto que se crea mediante la PageRouteHandler clase.It is equivalent to calling the Add method and passing a Route object that is created by using the PageRouteHandler class.

Consulte también:

MapPageRoute(String, String, String, Boolean, RouteValueDictionary, RouteValueDictionary) MapPageRoute(String, String, String, Boolean, RouteValueDictionary, RouteValueDictionary) MapPageRoute(String, String, String, Boolean, RouteValueDictionary, RouteValueDictionary) MapPageRoute(String, String, String, Boolean, RouteValueDictionary, RouteValueDictionary)

Permite definir rutas para las aplicaciones de formularios Web Forms.Provides a way to define routes for Web Forms applications.

public:
 System::Web::Routing::Route ^ MapPageRoute(System::String ^ routeName, System::String ^ routeUrl, System::String ^ physicalFile, bool checkPhysicalUrlAccess, System::Web::Routing::RouteValueDictionary ^ defaults, System::Web::Routing::RouteValueDictionary ^ constraints);
public System.Web.Routing.Route MapPageRoute (string routeName, string routeUrl, string physicalFile, bool checkPhysicalUrlAccess, System.Web.Routing.RouteValueDictionary defaults, System.Web.Routing.RouteValueDictionary constraints);
member this.MapPageRoute : string * string * string * bool * System.Web.Routing.RouteValueDictionary * System.Web.Routing.RouteValueDictionary -> System.Web.Routing.Route
Public Function MapPageRoute (routeName As String, routeUrl As String, physicalFile As String, checkPhysicalUrlAccess As Boolean, defaults As RouteValueDictionary, constraints As RouteValueDictionary) As Route

Parámetros

routeName
String String String String

El nombre de la ruta.The name of the route.

routeUrl
String String String String

Modelo de dirección URL de la ruta.The URL pattern for the route.

physicalFile
String String String String

Dirección URL física de la ruta.The physical URL for the route.

checkPhysicalUrlAccess
Boolean Boolean Boolean Boolean

Valor que indica si ASP.NET debe validar que el usuario está autorizado para obtener acceso a la dirección URL física (siempre se comprueba la dirección URL de la ruta).A value that indicates whether ASP.NET should validate that the user has authority to access the physical URL (the route URL is always checked). Este parámetro establece la propiedad CheckPhysicalUrlAccess.This parameter sets the CheckPhysicalUrlAccess property.

defaults
RouteValueDictionary RouteValueDictionary RouteValueDictionary RouteValueDictionary

Valores predeterminados de la ruta.Default values for the route.

constraints
RouteValueDictionary RouteValueDictionary RouteValueDictionary RouteValueDictionary

Restricciones que una solicitud de dirección URL debe cumplir para que sea procesada como esta ruta.Constraints that a URL request must meet in order to be processed as this route.

Devoluciones

Ruta que se agrega a la colección de rutas.The route that is added to the route collection.

Ejemplos

El ejemplo siguiente muestra cómo definir una ruta mediante este método.The following example shows how to define a route by using this method. Este ejemplo forma parte de un ejemplo más extenso que está disponible en el MapPageRoute información general del método.This example is part of a larger example that is available in the MapPageRoute method overview.

routes.MapPageRoute("ExpenseCurrentYearRoute",
    "ExpenseReportCurrent/{locale}", "~/expenses.aspx",
    false,
    new RouteValueDictionary 
        { { "locale", "US" }, { "year", DateTime.Now.Year.ToString() } },
    new RouteValueDictionary 
        { { "locale", "[a-z]{2}" }, { "year", @"\d{4}" } });
routes.MapPageRoute("ExpenseCurrentYearRoute",
    "ExpenseReportCurrent/{locale}", "~/expenses.aspx",
    false,
    new RouteValueDictionary(New With _
        { .locale = "US", .year = DateTime.Now.Year.ToString()}),
    new RouteValueDictionary(New With _
        { .locale = "[a-z]{2}", .year = "\d{4}" }))

Comentarios

Este método se proporciona para mayor comodidad de codificación.This method is provided for coding convenience. Equivale a llamar a la Add método y pasando un Route objeto que se crea mediante la PageRouteHandler clase.It is equivalent to calling the Add method and passing a Route object that is created by using the PageRouteHandler class.

Consulte también:

MapPageRoute(String, String, String, Boolean, RouteValueDictionary, RouteValueDictionary, RouteValueDictionary) MapPageRoute(String, String, String, Boolean, RouteValueDictionary, RouteValueDictionary, RouteValueDictionary) MapPageRoute(String, String, String, Boolean, RouteValueDictionary, RouteValueDictionary, RouteValueDictionary) MapPageRoute(String, String, String, Boolean, RouteValueDictionary, RouteValueDictionary, RouteValueDictionary)

Permite definir rutas para las aplicaciones de formularios Web Forms.Provides a way to define routes for Web Forms applications.

public:
 System::Web::Routing::Route ^ MapPageRoute(System::String ^ routeName, System::String ^ routeUrl, System::String ^ physicalFile, bool checkPhysicalUrlAccess, System::Web::Routing::RouteValueDictionary ^ defaults, System::Web::Routing::RouteValueDictionary ^ constraints, System::Web::Routing::RouteValueDictionary ^ dataTokens);
public System.Web.Routing.Route MapPageRoute (string routeName, string routeUrl, string physicalFile, bool checkPhysicalUrlAccess, System.Web.Routing.RouteValueDictionary defaults, System.Web.Routing.RouteValueDictionary constraints, System.Web.Routing.RouteValueDictionary dataTokens);
member this.MapPageRoute : string * string * string * bool * System.Web.Routing.RouteValueDictionary * System.Web.Routing.RouteValueDictionary * System.Web.Routing.RouteValueDictionary -> System.Web.Routing.Route
Public Function MapPageRoute (routeName As String, routeUrl As String, physicalFile As String, checkPhysicalUrlAccess As Boolean, defaults As RouteValueDictionary, constraints As RouteValueDictionary, dataTokens As RouteValueDictionary) As Route

Parámetros

routeName
String String String String

El nombre de la ruta.The name of the route.

routeUrl
String String String String

Modelo de dirección URL de la ruta.The URL pattern for the route.

physicalFile
String String String String

Dirección URL física de la ruta.The physical URL for the route.

checkPhysicalUrlAccess
Boolean Boolean Boolean Boolean

Valor que indica si ASP.NET debe validar que el usuario está autorizado para obtener acceso a la dirección URL física (siempre se comprueba la dirección URL de la ruta).A value that indicates whether ASP.NET should validate that the user has authority to access the physical URL (the route URL is always checked). Este parámetro establece la propiedad CheckPhysicalUrlAccess.This parameter sets the CheckPhysicalUrlAccess property.

defaults
RouteValueDictionary RouteValueDictionary RouteValueDictionary RouteValueDictionary

Valores predeterminados de los parámetros de la ruta.Default values for the route parameters.

constraints
RouteValueDictionary RouteValueDictionary RouteValueDictionary RouteValueDictionary

Restricciones que una solicitud de dirección URL debe cumplir para que sea procesada como esta ruta.Constraints that a URL request must meet in order to be processed as this route.

dataTokens
RouteValueDictionary RouteValueDictionary RouteValueDictionary RouteValueDictionary

Valores que están asociados a la ruta pero que no se utilizan para determinar si la ruta coincide con un modelo de dirección URL.Values that are associated with the route that are not used to determine whether a route matches a URL pattern.

Devoluciones

Ruta que se agrega a la colección de rutas.The route that is added to the route collection.

Excepciones

El parámetro routeUrl es null.The routeUrl parameter is null.

Ejemplos

El ejemplo siguiente muestra cómo definir una ruta mediante este método.The following example shows how to define a route by using this method. Este ejemplo forma parte de un ejemplo más extenso que está disponible en el MapPageRoute información general del método.This example is part of a larger example that is available in the MapPageRoute method overview.

routes.MapPageRoute("ExpenseDetailRoute",
    "ExpenseReportDetail/{locale}/{year}/{*queryvalues}", "~/expenses.aspx",
    false,
    new RouteValueDictionary 
        { { "locale", "US" }, { "year", DateTime.Now.Year.ToString() } },
    new RouteValueDictionary 
        { { "locale", "[a-z]{2}" }, { "year", @"\d{4}" } },
    new RouteValueDictionary 
        { { "account", "1234" }, { "subaccount", "5678" } });
routes.MapPageRoute("ExpenseDetailRoute",
    "ExpenseReportDetail/{locale}/{year}/{*queryvalues}", "~/expenses.aspx",
    false,
    new RouteValueDictionary(New With _
        { .locale = "US", .year = DateTime.Now.Year.ToString()}),
    new RouteValueDictionary(New With _ 
        { .locale = "[a-z]{2}", .year = "\d{4}" }),
    new RouteValueDictionary(New With _
        { .account = "1234", .subaccount = "5678" }))

Comentarios

Este método se proporciona para mayor comodidad de codificación.This method is provided for coding convenience. Equivale a llamar a la Add método y pasando un Route objeto que se crea mediante la PageRouteHandler clase.It is equivalent to calling the Add method and passing a Route object that is created by using the PageRouteHandler class.

Consulte también:

Se aplica a