2013-08-08 11 views
0

나는 이것이 쉬워야한다고 느낀다. 그러나 나는 고심하고있다.IIS URL 재 작성을 통한 가상 URL URL

http://www.mysite.com/folder/some-id-text 

및 URL이 여기에 직접 그 요구를 다시 작성해야 : 나는 사용자가이 URL로 이동 할 수 있도록하고 싶습니다

http://www.mysite.com/folder/index.aspx?id=some-id-text 

http://www.mysite.com/folder/some-id-text은 사용자가 지금까지 볼 수있는 유일한 URL이어야합니다.

답변

1

프로젝트 편집 Global.asax 파일에 아래 코드를 추가하십시오.

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

    public static void RegisterRoutes(System.Web.Routing.RouteCollection routes) 
    { 

     routes.MapPageRoute("somename", 
      "folder/{text-id}", 
      "~/index.aspx"); 
    } 

은 다음 index.aspx 당신이

string text_id = RouteData.Values["text-id"].ToString(); 

더 심판으로이 변수를 찾을 수 있습니다 http://code.msdn.microsoft.com/Easy-Steps-to-URL-2f792901

+0

감사합니다! 이것은 나를 위해 위대한 작품. 나는 모든 사람들이 차임 할 기회가 없었기 때문에 항상 정확한 대답을 표시하는 것을 주저하고 있지만, 내일 올바른 것으로 표시 할 것입니다. 도와 주셔서 다시 한 번 감사드립니다! –

+0

또한 "~/index.aspx"를 "~/folder/index.aspx"로 변경해야했습니다. –

관련 문제