繁体   English   中英

IIS 7.5下的ASP Net Web应用程序重定向到登录页面,但登录后出现错误http 404.0

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

我有一个使用ASP NET MVC开发的应用程序,并且已经在IIS中配置了虚拟目录。

我可以访问服务器文件夹,也可以访问位于http:localhost:8081 / application的应用程序

我已按预期重定向到位于/ Account / Login的登录页面,但是当我使用用户名/密码登录时,我得到了Erro HTTP 404.0-Not Found。

为什么会这样呢?

编辑:

控制器:

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

}

您的web.config可能应在其loginUrl1属性中包含虚拟目录。

尝试像这样更改web.config:

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

问题不在于我的asp net应用,而在于IIS配置。 IIS负责人解决了该问题。 谢谢

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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