How to enable basic authentication before the processing the request in asp.mvc? (Description inside)


This question already has an answer here:


here give u demo which is define about authenticate of client

here is about controller code

   public ActionResult LogOn(LogOnModel model, string returnUrl)
        if (ModelState.IsValid)
            var userInfo = new UserInfo
                UserName = model.UserName,
                Password = model.Password,
                //AppType = "Web"

            var service = new ATWMSService();
                Session["UserId"] = service.GetUserId(userInfo.UserName);
                FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                    && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    return Redirect(returnUrl);
                return Redirect("~/");
            ModelState.AddModelError("","The user name or password provided is incorrect.");

        // If we got this far, something failed, redisplay form
        return View(model);

Need Your Help

Java Web App Security using Cookies

java security http cookies

I'm finishing a Cattle Drive assignment where a small Java web application manages a movie library for the client. The assignment is to put some security on the application using cookies, so that a

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.