개발언어/ASP.NET
urlMappings URL하기
by 엔돌슨
2008. 3. 12.
신가하네 ~
TreeView에 메뉴를 구성하고 이걸 누를때 다른 경로로 매핑할 수 있다
그런데 이걸이용하여 경로를 숨길수 있다
web.config에 이렇게 하고
<urlMappings enabled="true">
<add url="~/Module.aspx?index=1" mappedUrl="~/실재경로1~.aspx" />
<add url="~/Module.aspx?index=2" mappedUrl="~/실재경로2~.aspx" />
</urlMappings>
SiteMap에서 이렇게하고 테스트 해보자 ^^
<siteMapNode title="MappingTest" url="./숨길후나타날페이지.aspx?index=1" description="매핑테스트" core="true" link="true" />
<siteMapNode title="MappingTest" url="./숨길후나타날페이지.aspx?index=2" description="매핑테스트" core="true" link="true" />
실재로는 실재경로1~ 이나 실재경로2~로 접속된다
나타나기는 숨길후나타날페이지.aspx로 보여지는 것이다 ^^
This tutorial will show you how to use URL mapping technology in ASP.NET 2.0 and VB.NET.
Download the Full Working Version of this Project written with Visual Studio.NET VB.NET 2005 Here!
Looking for the C#.NET 2005 Version? Click Here!
Looking for more ASP.NET Tutorials? Click Here!
The URL mapping feature uses configuration information stored in web.config to remap incoming requests to a different URL. The remapping occurs prior to any other processing for the inbound request. Although the sample below demonstrates remapping a page request, any arbitrary file type can have its request remapped to a different URL.
At first you need to build a sitemap file Web.sitemap. The code as following:
<?xml version="1.0" encoding="utf-8" ?> <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0"> <siteMapNode url="~/UrlMappingVB.aspx" title="Home Page" description="This is the home page" > <siteMapNode url="~/Category.aspx" title="Categories" description="Information Categories" > <siteMapNode title="News" description="News" url="~/News.aspx" /> <siteMapNode title="Games" description="Games" url="~/Games.aspx" /> <siteMapNode title="Health" description="Health" url="~/Health.aspx" /> </siteMapNode> </siteMapNode> </siteMap>
|
Secondly, please build a web.config file. The code as following:
<?xml version="1.0" ?> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.web> <urlMappings enabled="true"> <add url="~/News.aspx" mappedUrl="~/UrlMappingVB.aspx?category=news" /> <add url="~/Category.aspx" mappedUrl="~/UrlMappingVB.aspx?category=default" /> <add url="~/Games.aspx" mappedUrl="~/UrlMappingVB.aspx?category=games" /> <add url="~/Health.aspx" mappedUrl="~/UrlMappingVB.aspx?category=health" /> </urlMappings>
</system.web> </configuration>
| The front end SiteMapPathTreeViewNavigationVB.aspx page looks something like this:
<table> <tr> <td><asp:SiteMapDataSource Runat=server ID="SiteMapDataSource1" /> <br /></td> </tr> <tr> <td> <asp:Label Runat=server Text="TreeView" id="Label3" ForeColor="#ff3366" /> <asp:TreeView ID="TreeView1" DataSourceID="SiteMapDataSource1" Runat=Server /> </td> </tr> <tr> <td> The current virtual path for the request is:<b> <% Response.Write(Request.Path)%></b>. <br /> The value of the category querystring variable is:<b> <% Response.Write(Server.HtmlEncode(Request.QueryString("category")))%></b>. <br /> However, the original path that was requested before it was remapped is:<b> <% Response.Write(Request.RawUrl)%></b>. </td> </tr> </table>
|
Download the Full Working Version of this Project written with Visual Studio.NET VB.NET 2005 Here!
Looking for the C#.NET 2005 Version? Click Here!
Looking for more ASP.NET Tutorials? Click Here!
|