Problem in C# .net web application Redirection -
i coded httpmodule , added correctly site give me error when run it:
**the page isn't redirecting
firefox has detected server redirecting request address in way never complete.**
using system; using system.web; using system.net; using system.text; using system.io; namespace commonrewriter { public class parseurl : ihttpmodule { public parseurl() { } public string modulename { { return "commonrewriter"; } } public void init(httpapplication application) { application.beginrequest += new eventhandler(application_beginrequest); application.endrequest += new eventhandler(application_endrequest); } private string parseandreapply(string texttoparse) { string final = null; if (texttoparse.contains(".") && texttoparse.contains("example.com")) { string[] splitter = texttoparse.split('.'); if (splitter[0].tolower() != "www" &&(splitter[2].tolower()).contains("blog")) { final = ("www.example.com/blog/?tag=/" + splitter[0]); } else { final = texttoparse; } } else { final = texttoparse; } return final; } void application_beginrequest(object sender, eventargs e) { httpapplication application = (httpapplication)sender; httpcontext context = application.context; string req = context.request.filepath; context.response.redirect(parseandreapply(req)); context.response.end(); } void application_endrequest(object sender, eventargs e) { } public void dispose() { } } }
every begin request redirecting, same url. need check make sure redirection necessary before calling context.response.redirect()
.
Comments
Post a Comment