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

左心房为你撑大大i 提交于 2019-12-12 04:45:53

问题


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 }
        );
    }
}

}


回答1:


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>



回答2:


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



来源:https://stackoverflow.com/questions/13620095/asp-net-web-application-under-iis-7-5-redirect-to-a-login-page-but-gives-error-h

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!