2013-03-12 1 views
1

안녕하세요 친구는 누구나이 문제를 해결할 수 있습니다. 저는 정말 견과를 읽었습니다. 기사와 자습서도 읽었으며 그에 따라 코딩도 완료했습니다. 점점 오류 메신저URL을 asp.net 4.0으로 재 작성

A route named 'xxxxx' ould not be found in the route collection. 
Parameter name: name 

글로벌 asax에게 있습니다 내가 버튼을 클릭 이벤트에 다음과 같이 아래로 코딩 한 페이지 test1에서

<%@ Application Language="C#" %> 
<%@ Import Namespace="System.Web.Routing" %> 

<script runat="server"> 

    public static void RegisterRoutes(RouteCollection routes) 
    { 
     routes.MapPageRoute("test2-testurl", "test2/{category}", "~/test2.aspx"); 
    } 
    void Application_Start(object sender, EventArgs e) 
    { 
     RegisterRoutes(RouteTable.Routes); 
     // Code that runs on application startup 

    } 

    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> 

:

protected void Button1_Click(object sender, EventArgs e) 
{ 

    string url = Page.GetRouteUrl("test2-testurl", new { category = "laptops" }); 
    Response.RedirectToRoute(url); 

} 
+0

감사 –

답변

0

은 아마도 (이 시도 'test2'삭제) :

routes.MapPageRoute("test2-testurl", "{category}", "~/test2.aspx"); 

업데이트 : 이 방법을 페이지로

Response.Redirect("page2/laptops"); 

예 리디렉션 단지 시도 : 편집

// add route 
routes.MapPageRoute("ad-view", "view/{ad-id}", "~/ad_view.aspx"); 
// on page I usualy bind values in repeater to links like this: 
<asp:HyperLink ID="TitleHL" NavigateUrl='<%# "view/" + Eval("ad_id") %>' runat="server"> 
// to redirect from code-behind i'll use: 
Responce.Redirect("view/" + ad_id); 
+0

여전히 대답을 업데이트 같은 오류 유진 –

+0

를 gettting 구애를 -) –

+0

나는 여전히 리소스를 찾을 수 없기 때문에 오류가 계속 발생하므로 프로그래밍과 함께 web.config 파일에 무언가를 추가해야합니다. –