views:

92

answers:

0

Hi Guys!! I have developed the authenticated rss feed using the basic http authentication for my site.I also have the admin module for the site which uses the Asp.net Forms Authentication .Both are in the same project.When i turn on the forms authentication module to None in my web.config.My rss feed authentication works fine(the browser pop up the dialog box for the username and password) and upon entering the username and password the rss feed gets displayed.But with forms authentication turn on when i click the rss feed link i am getting redirected to the administrator login page.

If i set my authentication mode to none than the feed works like dream but the admin module do not work as it uses forms authentication.

How can i resolve the conflict for that one.I am using the asp.net mvc filter on my feed contoller to pop up the dialog box for the username and password.

Code::

[RequireBasicAuthentication]
public ActionResult RssFeedGlobal() { var cred=System.Text.ASCIIEncoding.ASCII.GetString(Convert.FromBase64String(Request.Headers["Authorization"].Substring(6))).Split(':'); var user = new { Name = cred[0], Pass = cred[1] }; var req = HttpContext.Request; if (String.IsNullOrEmpty(req.Headers["Authorization"])) { PromtUserNameAndPassword(); }

try{ //LOGIC FOR EXTRACTING THE FEED }

catch { //Exception } }//Controller close

//Code for the filter public class RequireBasicAuthentication : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) {
var req = filterContext.HttpContext.Request; if (String.IsNullOrEmpty(req.Headers["Authorization"])) { var res = filterContext.HttpContext.Response; res.StatusCode = 401; res.AddHeader("WWW-Authenticate", "Basic realm=\"ImanageProject\""); res.End(); } } }

Please help me.Thanks in advance.