473,396 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

fttphandler

hi ,
i am building site that the user can enter by virtual path .
for example www.mysite.com/car/bigCars/Mec/default.aspx
this path "/car/bigCars/Mec/default.aspx" do not exist .
what i what is that my jttphandler will catch the url , and user will
surf the site
thinking he is actually in that url .
what i did is that i do catch the url and i transferring him to
anouther page by preserving the url that the user entered .

ok , so the problem goes like that ,
i have link in the page that i did server.transfer to the user and i
want that to preserve
the url to . instead i am getting "page not found" .
how do i do that ?
Please help .
this is my code :
Handler :
public class DomainHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.Write(context.Request.Url.ToStrin g());
context.Server.Transfer("/WebSite/CategoryPage.aspx");
}
public bool IsReusable
{
get
{
return true;
}
}
}
web.config :
<httpHandlers>
<add verb="*" path="default.aspx"
type="DomainFilter.DomainHandler"/>
</httpHandlers>

May 22 '06 #1
2 1077
HttpHandlers must be also registered in IIS.

Open IIS management tool, right click on the virtual directory,
Properties and click the "Configuration" button in the first tab.

Then add C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspne t_isapi.dll
for the .* files with "Check That files exist" checkbox unchecked.

Hope this helps.

Regards,
Tasos

May 22 '06 #2
thanks ,
but i did it with vitual files .
public class DomainHandler : IHttpHandler
{
protected const string siteName = "WebSite";
protected const string firstRunFile = "default.aspx";

#region GetLogicPath
/// <summary>
/// set the physical path
/// </summary>
/// <param name="requestedUrl">the url</param>
/// <param name="runFile">the virtual file that runs</param>
/// <returns>returns the path to be match the physical path in the
web.config</returns>
protected string GetLogicPath(string requestedUrl, string runFile)
{
int fileL = Path.GetFileName(requestedUrl).Length;
int runFileL = runFile.Length;
return requestedUrl.Substring(0, siteName.Length + 2) +
requestedUrl.Substring(requestedUrl.Length - runFileL);
}
#endregion

public void ProcessRequest(HttpContext context)
{
string requestedUrl;
string targetUrl;
string newUrl;
string param = string.Empty;
string runFile = string.Empty;

requestedUrl = context.Request.RawUrl;
newUrl = requestedUrl;
runFile = Path.GetFileName(requestedUrl);
if (requestedUrl.Length != 21)
{
if (requestedUrl.IndexOf("?") >= 0)
{
runFile = runFile.Substring(0, runFile.IndexOf("?"));
newUrl = GetLogicPath(requestedUrl.Substring(0,
requestedUrl.IndexOf("?")),runFile);
param =
requestedUrl.Substring(requestedUrl.IndexOf("?"));
}
else
{
newUrl = GetLogicPath(requestedUrl, runFile);
}
}
targetUrl = ConfigurationManager.AppSettings[newUrl];
if (targetUrl!=null)
context.Server.Transfer(targetUrl + param);
}

<appSettings>
<add key="ConnectionString" value="user id=ChadMart; data
source=TEAM; initial catalog=ChadMart;pwd=kiska01"/>
<add key="FieldPerPage" value="4"></add>
<add key="PagePerWindow" value="5"></add>
<add key="url" value="http://localhost:2998/Website/"></add>
<add key="/WebSite/default.aspx"
value="~/Front/CategoryPage.aspx"/>
<add key="/WebSite/Items.aspx" value="~/Front/ItemsFrames.aspx"/>
<add key="/WebSite/ItemsS.aspx" value="~/Front/ItemSite.aspx"/>
<add key="/WebSite/head.aspx" value="~/Front/header.aspx"/>
<add key="/WebSite/ErrorMsg.aspx" value="~/Front/Error.aspx"/>
</appSettings>

<system.web>
<httpHandlers>
<add verb="*" path="*/Front/*.aspx"
type="System.Web.UI.PageHandlerFactory"/>
<add verb="*" path="*.aspx" type="DomainHandler"/>
</httpHandlers>

May 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.