I have a folder with multiple .aspx pages that I want to restrict access to. I have added web.config to that folder with
.
The
Check it out. Hope this helps.
#region [ Imports ]
using System;
using System.Web;
using System.Web.Security;
#endregion
namespace Foo.Handlers
{
public class AuthModule : IHttpModule
{
#region IHttpModule Members
public void Init(HttpApplication application)
{
application.PostReleaseRequestState += delegate(object s, EventArgs e)
{
if (application.Response.StatusCode == 401)
application.Response.Redirect(FormsAuthentication.LoginUrl + "?ReturnUrl=" + HttpUtility.UrlEncode(application.Request.RawUrl), true);
};
}
public void Dispose() { }
#endregion
}
}