我有一个可以在Visual Studio中运行的MVC3应用程序,但是当发布到web服务器上时,请求的URL: /App/Account/LogOn会返回404。问题是我从来没有创建过帐户控制器或操作LogOn。我不确定为什么要加载帐户/登录,也不知道如何修复它。谢谢。
我的global.asax.cs文件如下所示:
public class MvcApplication : NinjectHttpApplication
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
//filters.Add(new HandleErrorAttribute());
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
// Create ninject kernel
protected override IKernel CreateKernel()
{
var kernel = new StandardKernel();
// Add bindings
kernel.Bind<IEmployeeRepository>().To<EFEmployeeRepository>();
kernel.Bind<IDocumentRepository>().To<DocumentRepository>();
// Load kernel
kernel.Load(Assembly.GetExecutingAssembly());
return kernel;
}
// Replaces App_Start() when using Ninject
protected override void OnApplicationStarted()
{
base.OnApplicationStarted();
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
}发布于 2011-09-14 21:36:44
我最好的猜测是这来自您的web.config,因为这是您创建新MVC项目时的默认登录页面。当你尝试点击一个应用了[Authorize]属性的动作时,你会被重定向到这里。
检查是否有这样的部分:
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>如果您有自己的登录页面,则需要在此处查看该URL,否则,如果您没有使用安全性,则检查带有[Authorize]属性的操作。
https://stackoverflow.com/questions/7417129
复制相似问题