I need map HttpHandler on Handler.xml.
I wrote to web.config
I also try map IIS, Home direcortory to .xml and still write Page can't load.
Thanks for help and ideas.
Tomas
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Roei BarPosted Aug 6, 2009, 7:23 AM
on web config add this:
and here is the Handler
using System;
namespace Foo
{
public class Redirector : System.Web.IHttpHandler
{
void System.Web.IHttpHandler.ProcessRequest(System.Web.HttpContext context)
{
string userAgent = context.Request.UserAgent;
if (userAgent != null && userAgent.Length > 0)
{
// If they aren't FeedBurner (optional example check)
if (userAgent.StartsWith("FeedBurner") == false)
{
string redirect = String.Empty;
string physicalpath = System.IO.Path.GetFileName(context.Request.PhysicalPath).ToUpperInvariant();
switch (physicalpath)
{
case "BAR.XML":
redirect = "http://feeds.feedburner.com/Bar";
break;
case "FOO.XML":
redirect = "http://feeds.feedburner.com/Foo";
break;
}
if (redirect != String.Empty)
{
context.Response.Redirect(redirect); //temporary redirect
//context.Response.StatusCode =(int) System.Net.HttpStatusCode.MovedPermanently; //permanent HTTP 301
//context.Response.Status = "301 Moved Permanently";
//context.Response.RedirectLocation = redirect;
return;
}
}
}
context.Response.ContentType = "application/xml";
context.Response.TransmitFile(context.Request.PhysicalPath);
}
bool System.Web.IHttpHandler.IsReusable
{
get { return true; }
}
}
}
}
}