URL 재 작성은 설명하는 것과 다른 문제를 해결합니다.
경로 location
에 대한 요청을 처리하고 마지막 세그먼트를 구문 분석하여 조회 키를 얻은 HttpHandler를 사용하여 실행을 .aspx에 전달할 수 있습니다. 실행을 일반 페이지로 전달하더라도 URL은 입력 된 그대로 유지됩니다.
예제를 제공합니다. 한번 해봐. here is a sample project
LocationHandler.cs
using System.IO;
using System.Web;
namespace DBHandler
{
public class LocationHandler : IHttpHandler
{
#region IHttpHandler Members
public void ProcessRequest(HttpContext context)
{
HttpRequest request = context.Request;
string page = Path.GetFileNameWithoutExtension(request.Url.Segments[request.Url.Segments.Length - 1]);
// for url ~/location/location33.aspx page will be 'location33'
// do something interesting with page, perhaps
context.Server.Execute("~/locations.aspx?locationId=" + context.Server.UrlEncode(page));
}
public bool IsReusable
{
get { return false; }
}
#endregion
}
}
locations.aspx
<%@ Page Language="C#" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Request["locationId"];
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
Web.config의 발췌
...
<system.web>
...
<httpHandlers>
<add verb="*" path="location/*.*" type="DBHandler.LocationHandler"/>
</httpHandlers>
</system.web>
...
니 달성하고자하는 것에 대해 더 자세히 설명해주십시오. –