Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to use friendly url. But after redirecting to child page , again it is going to master page. so it keeps on recycling.
I am not able to guess what s happening.

I installed frienly url package. then this is the routeconfig.cs

C#
public static class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
var settings = new FriendlyUrlSettings();
settings.AutoRedirectMode = RedirectMode.Permanent;
routes.EnableFriendlyUrls(settings);
}
}




2. Global.asax.cs

C#
protected void Application_Start(object sender, EventArgs e)
{
RouteConfig.RegisterRoutes(RouteTable.Routes);
}


3.Master page

4.Home Page.

5.sportschildpage.



i put ispostpack condition in all form and i made it home.aspx as a startup page. so it displays nicely without aspx.

everybody knows debugger cycling. i am telling what is happening for my case.



when i run the project, debugger went to application_start and called the RegisterRoutes function then it went to page load of home.aspx.cs then it went page load of master page. then home page displayed without aspx. i have a button in home aspx. in click event i redirected to sportschildpage. so, now when i click button, debugger calls page load . i put ispostpack condittion true and false, so debugger went to master page then it goes to click event. once click event called , it redirects to sporstchildpage.



But , Here is the problem after completion of pageload of sporstchild page, it is not rendering to browser. again it calls master page load and ispostpack gets false. so again debugger calls sporstchild page. like wise roundtrip is happening again and again more than 3 times.



where i am doing mistake. help needed.
Posted
Updated 27-Jan-15 1:56am
v2

1 solution

You should not check IsPostBack in the master page...This is the master of all (or most) pages for you application and for that it is called from each end every one...
So for your scenario:
The first time master page called for the home page and for that page IsPostBack is true, as this is a reload of the page during the click event handling cycle.
The second time master page called for the sportschildpage and for that page IsPostBack is false, as this is the very first time you load it!!!
The one and only place you should handle click event (or any control event) is inside the page to which the button (control) belongs...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900