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 } } modules.
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 } }.
Thanks. I'll give this one a try. – Brian Kim Dec 4 '09 at 20:26 There's no chance to intercept in between to replace ReturnUrl with RawUrl.
– Brian Kim Dec 7 '09 at 18:52 Status code 401 is never captured... It goes protected page (302) -> login with ReturnUrl (200). – Brian Kim Dec 7 '09 at 19:15.
Create the following control adapter to rewrite the form tag with the for the action attribute. I used this a ASP. NET 2.0 app in conjunction with the Intelligencia url rewriter.
I got it from this blog post from the Gu. Put this class in your App_Code folder: using System. IO; using System.
Web; using System.Web. UI; public class FormRewriterControlAdapter : System.Web.UI.Adapters. ControlAdapter { protected override void Render(HtmlTextWriter writer) { base.
Render(new RewriteFormHtmlTextWriter(writer)); } } public class RewriteFormHtmlTextWriter : HtmlTextWriter { public RewriteFormHtmlTextWriter(TextWriter writer) : base(writer) { base. InnerWriter = writer; } public RewriteFormHtmlTextWriter(HtmlTextWriter writer) : base(writer) { this. InnerWriter = writer.
InnerWriter; } public override void WriteAttribute(string name, string value, bool fEncode) { // If the attribute we are writing is the "action" attribute, and we are not on a sub-control, // then replace the value to write with the raw URL of the request - which ensures that we'll // preserve the PathInfo value on postback scenarios if ((name == "action")) { if (HttpContext.Current. Items"ActionAlreadyWritten" == null) { // Because we are using the UrlRewriting. Net HttpModule, we will use the // Request.
RawUrl property within ASP. NET to retrieve the origional URL // before it was re-written. You'll want to change the line of code below // if you use a different URL rewriting implementation.
Value = HttpContext.Current.Request. RawUrl; // Indicate that we've already rewritten the 's action attribute to prevent // us from rewriting a sub-control under the control HttpContext.Current. Items"ActionAlreadyWritten" = true; } } base.
WriteAttribute(name, value, fEncode); } } Then, create this . Browser file in your App_Browsers folder.
Seems like this one takes care of URL of the page on postback. What I'm looking for is the clean rewrite Url for automatically generated ReturnUrl querystring when you hit a restricted page unauthenticated. – Brian Kim Dec 4 '09 at 20:10 I believe it should do that too, but I'm not sure.
– craigmoliver Dec 4 '09 at 20:30.
I ended up checking for existence of ReturnUrl in the Url and replacing it with RawUrl in EndRequest stage in Global.asax. This works for me for now... This blog post helped me setting it up. Protected void Application_EndRequest(object sender, EventArgs e) { string redirectUrl = this.Response.
RedirectLocation; if (!this.Request.RawUrl. Contains("ReturnUrl=") &&!string. IsNullOrEmpty(redirectUrl)) { this.Response.
RedirectLocation = Regex. Replace(redirectUrl, "ReturnUrl=(?'url'^&*)", delegate(Match m) { return string. Format("ReturnUrl={0}", HttpUtility.
UrlEncode(this.Request. RawUrl)); }, RegexOptions. Singleline | RegexOptions.
IgnoreCase | RegexOptions. ExplicitCapture); } }.
If you are using ASP. NET 3.5, use ASP. NET UrlRouting instead.
But you must check the authorization manualy. chriscavanagh.wordpress.com/2008/03/11/a....
Thanks for info, but I'm using 2.0 and cannot change everything to use routing... – Brian Kim Dec 1 '09 at 19:37.
ReturnURL is handled internally by the ASP.NET framework. Handle ReturnUrl.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.