简体   繁体   中英

asp net web application under IIS 7.5 redirect to a login page but gives error http 404.0 after log-in

I have a application developed using ASP NET MVC and I have configured a virtual direcotry in IIS.

I can access the server folder and also my app located in http:localhost:8081/application

I am redirect to a login page located /Account/Login as expected but when I log in using my username/password I am getting an Erro HTTP 404.0 - Not Found.

Why this behavior?

Edit:

Controller:

    //
    // POST: /Account/Login
    [HttpPost]
    [ValidateAntiForgeryToken]
    [AllowAnonymous]
    public ActionResult Login(LoginModel model, string returnUrl)
    {
        MembershipProvider mp = Membership.Provider;

        if (ModelState.IsValid && mp.ValidateUser(model.UserName, model.Password))
        {
            FormsAuthentication.SetAuthCookie(model.UserName, false);
            return RedirectToAction("Index", "Home");
        }

        // If we got this far, something failed, redisplay form
        ModelState.AddModelError("", "Username ou Password incorreto!.");

        return View(model);
    }  

RouteConfig:

namespace tgpwebged { public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional }
        );
    }
}

}

Possibly you web.config should include the virtual directory in it's loginUrl1 attribute.

Try changing your web.config like this:

<authentication mode="Forms">
      <forms loginUrl="tgpwebged/Account/Login"  />
</authentication>

The problem was not with my asp net app, but with the IIS configuration. Guys in charge of IIS fix the problem. Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM