8
Reply

create new url using httphandler

sadi

sadi

Jan 4 2011 2:09 AM
9.9k

Hi. i show articles names on default.aspx. when i click an article's nam, it will redirect to detay.aspx. i send info using querystring.
response.redirect(""detay.aspx?id="+artid+"&name="+artname);//artid is id of article and rtname is header of article.
i want this url to show like ../detay/{articlename}. for doing this, i try httphandler. but it gives error. My codes are:
 

public void ProcessRequest(HttpContext context)
{
string path = context.Request.Path;
int ind = path.LastIndexOf('.');
string newpath = path.Substring(0, ind );
string detayadi = context.Request.QueryString["adi"];
newpath = newpath +
"/" + detayadi;
context.RewritePath(newpath);
IHttpHandler hnd = PageParser.GetCompiledPageInstance(newpath, null, context);
hnd.ProcessRequest(context);
}

this is my httphandlr code. Request.QueryString["adi"] is header of article.
in webconfig:
 

<
httpHandlers>
<
add verb="*" path="*/detay.aspx" type="MyHandler.UrlHandler,MyHandler" validate="true"/>

</
httpHandlers>
 
i added this. it give error like url doesn't find. how can i do this?Thanks.

Answers (8)