When we added webya to our site it prompt with authentication. When we cancelled authentication page appear without any problem.
After investigation we found webya try to access /pages. To ignore this problem we added HTTPModule to escape this authetication. Sample Code as below:
public class BadRequestHandler : IHttpModule { /// /// Don't let the response be cached by the browser. Set up the status code /// and return. /// public void ProcessRequest(HttpApplication context) { context.Response.Cache.SetCacheability(HttpCacheability.NoCache); context.Response.Cache.SetNoStore(); context.Response.Cache.SetExpires(DateTime.MinValue); if (context.Request.Url.AbsolutePath.ToLower().EndsWith("/pages/")) ParseStatusCode(context, 200); } /// /// Actually set up the status code at this point, and return. /// protected void ParseStatusCode(HttpContext context, int statusCode) { context.Response.StatusCode = 200; context.Response.End(); } public bool IsReusable { get { return true; } }
public void Dispose() { }
public void Init(HttpApplication context) { context.BeginRequest += new EventHandler(context_BeginRequest); }
void context_BeginRequest(object sender, EventArgs e) { //System.Web.HttpContext.Current.Response.Write("handler started"); System.Web.HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); System.Web.HttpContext.Current.Response.Cache.SetNoStore(); System.Web.HttpContext.Current.Response.Cache.SetExpires(DateTime.MinValue); if (System.Web.HttpContext.Current.Request.Url.AbsolutePath.ToLower().EndsWith ("/pages/")) { ParseStatusCode(System.Web.HttpContext.Current, 200); } } }
|
No comments:
Post a Comment