6
Answers

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

Laxman Sharma

Laxman Sharma

8y
224
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)
0
Laxman Sharma

Laxman Sharma

NA 54 3.7k 8y
Requesting you all respected members please help me out to solve it .
I want to route the first page of the application using Global.asax
0
Laxman Sharma

Laxman Sharma

NA 54 3.7k 8y
Want to do it with Global.asax
0
Vinay Singh

Vinay Singh

NA 5.9k 126.1k 8y
Hi
Try the below link
http://stackoverflow.com/questions/686681/url-rewrite-from-default-aspx-to
http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
0
Laxman Sharma

Laxman Sharma

NA 54 3.7k 8y
I have done for all pages but its not refelecting in default/First page while page loading
0
kalu singh rao

kalu singh rao

NA 6.4k 63.8k 8y
You can find here to write code for rewrite url in global.asax
 
https://msdn.microsoft.com/en-us/library/cc668201.aspx
 
http://www.codeproject.com/Articles/77199/URL-Routing-with-ASP-NET-4-0 
 
http://stackoverflow.com/questions/686681/url-rewrite-from-default-aspx-to 
0
Laxman Sharma

Laxman Sharma

NA 54 3.7k 8y
Any quick response will be appreciated please .