6
Answers

URL Rewriting for the Default /First page of the asp.net c#

Laxman Sharma

Laxman Sharma

8y
220
1

I am working on a web based application ,I am going to rewrite the url of the pages using Global.asax file .

I have successfully done all the pages but I could not able to do the first page of the application which is initiate while loading the application .

I have used below codes in global.asax file :

 protected void Application_Start(object sender, EventArgs e) { SetRouting(System.Web.Routing.RouteTable.Routes); } private void SetRouting(System.Web.Routing.RouteCollection routeCollection) {           routeCollection.MapPageRoute("log", "Login", "~/log.aspx");          routeCollection.MapPageRoute("Controlpannel", "Master", "~/Controlpannel.aspx"); //routeCollection.MapPageRoute("QueryStringPage", "QueryString/{Id}", "~/QueryString.aspx", true, new RouteValueDictionary(new { Id = "0" })); }
and using below code while page loading :
 
protected void Page_Load(object sender, EventArgs e) { Response.Redirect(GetRouteUrl("log", null)); }

Please guide me what code should i need to write below page load ,My rest of pages are working fine with same code .

Regards L

 
Answers (6)