Created
October 10, 2012 17:20
-
-
Save lazarofl/3867042 to your computer and use it in GitHub Desktop.
Global.asax with route tables for url rewriting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Application Language="C#" %> | |
<%@ Import Namespace="System.Web.Routing" %> | |
<script RunAt="server"> | |
/// <summary> | |
/// Add routes to application | |
/// </summary> | |
void RegisterRoutes(RouteCollection routes) | |
{ | |
#region Rotas amigáveis | |
//routes.MapPageRoute("nome_da_rota", "url_amigavel", "~/caminho_do_aspx"); | |
routes.MapPageRoute("TiraDuvidas/Ranking", "TiraDuvidas/Ranking", "~/TiraDuvidas/Ranking/ProcessRanking.aspx"); | |
routes.MapPageRoute("TiraDuvidas/MaisPopulares", "TiraDuvidas/MaisPopulares", "~/TiraDuvidas/Default.aspx", false, new RouteValueDictionary { { "parameter", "1" } }, null); | |
routes.MapPageRoute("{QuestionId}/{QuestionCategoryId}/TiraDuvidas/{QuestionCategoryName}/{QuestionName}", "{QuestionId}/{QuestionCategoryId}/TiraDuvidas/{QuestionCategoryName}/{QuestionName}", "~/TiraDuvidas/View.aspx", false, null, new RouteValueDictionary { { "QuestionCategoryId", @"\d+" }, { "QuestionId", @"\d+" } }); | |
#endregion | |
} | |
void Application_Start(object sender, EventArgs e) | |
{ | |
RegisterRoutes(RouteTable.Routes); | |
} | |
void Application_End(object sender, EventArgs e) | |
{ | |
// Code that runs on application shutdown | |
} | |
void Application_Error(object sender, EventArgs e) | |
{ | |
// Code that runs when an unhandled error occurs | |
} | |
void Session_Start(object sender, EventArgs e) | |
{ | |
// Code that runs when a new session is started | |
} | |
void Session_End(object sender, EventArgs e) | |
{ | |
// Code that runs when a session ends. | |
// Note: The Session_End event is raised only when the sessionstate mode | |
// is set to InProc in the Web.config file. If session mode is set to StateServer | |
// or SQLServer, the event is not raised. | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment