Monday, May 16, 2011

Url rewritting work in IIS-7.0

1. Take the Web form


 <div>
        <a href="page1">Page 1</a><br />
        <a href="page2">Page 2</a><br />
        <a href="page3">Page 3</a>
</div>


2.pagge1 ===redirect to second page with id
3.in code behind page od second
 if (Request.QueryString["id"] != null)
        {
            string s = Request.QueryString["id"].ToString().Trim();
            switch(s)
            {
                case "1":
                    Response.Write("this is page 1");
                    break;
                case "2":
                    Response.Write("this is page 2");
                    break;
                case "3":
                    Response.Write("this is page 3");
                    break;
            }
}


4.in the web config file

 <urlMappings>
      <add url="~/page1" mappedUrl="~/jquery.aspx?id=1"/>
      <add url="~/page2" mappedUrl="~/jquery.aspx?id=2"/>
      <add url="~/page3" mappedUrl="~/jquery.aspx?id=3"/>
 </urlMappings>




  http://www.youtube.com/watch?v=FRhQhp3VKys



http://peterkellner.net/2008/08/24/urlrewrite-with-aspnet-urlrewriter-wildcard-mapping-iis6-iis7/------------------

No comments:

Post a Comment