asp.net中友好URL中的问题 [英] Problem in friendly URL in asp.net

查看:71
本文介绍了asp.net中友好URL中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用友好的网址。但是在重定向到子页面之后,它再次进入母版页面。所以它继续回收。

我无法猜测发生了什么。



我安装了frienly url包。那么这就是routeconfig.cs



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

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







2. Global.asax.cs

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





3.Master page



4。主页。



5.sportschildpage。







i将 ispostpack 所有形式的条件,并将其作为启动页面 home.aspx 。所以它没有aspx显示得很好。



每个人都知道调试器循环。我告诉我的情况正在发生什么。







当我运行项目时,调试器去了到application_start并调用 RegisterRoutes 函数然后它转到页面加载home.aspx.cs 然后它去了页面加载主页面。然后显示没有aspx的主页。我在家庭aspx有一个按钮。在点击事件中,我重定向到sportschildpage。所以,现在当我点击按钮时,调试器调用页面加载。我把ispostpack condittion设置为true和false,所以调试器转到master页面然后转到click事件。一旦调用click事件,它就会重定向到sporstchildpage。







但是,这是sporstchild页面页面加载完成后的问题,它不是渲染浏览器。再次调用master页面加载并且ispostpack变为false。所以再次调试器调用sporstchild页面。喜欢明智的往返一次又一次地发生超过3次。







我在哪里做错了。需要帮助。



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.

推荐答案

您不应该在母版页中检查IsPostBack ...这是您应用程序的所有(或大多数)页面的主页,为此从每一端都被调用...

所以对于你的场景:

第一次调用主页和主页的页面IsPostBack是真的,如同这是在点击事件处理周期中重新加载页面。

第二次调用sportschildpage页面并且该页面的IsPostBack是假的,因为这是你第一次加载它! !!

你应该处理点击事件(或任何控制事件)的唯一地方是在按钮(控件)所属的页面内...
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...


这篇关于asp.net中友好URL中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆