日期:2014-05-17  浏览次数:20469 次

求教MVC3中authentication问题
最近项目中需要对权限进行认证,在web.config文件中加入了以下内容
<authentication mode="Forms">
  <forms loginUrl="~/Account/Logon" timeout="2880"/>
</authentication>
<authorization>
  <deny users="?"/>
</authorization>
<location path ="LoadPage">
  <system.web>
  <authorization>
  <allow users="?"/>
  </authorization>
  </system.web>
</location>

同时Global.asax中增加了一条路由规则:
routes.MapRoute(
  "Default", // Route name
  "{controller}/{action}/{id}", // URL with parameters
  new { controller = "LoadPage", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);

问题在于,在URL中拼写:http://127.0.0.1:81/LoadPage/Index 可以正常访问
但是http://127.0.0.1:81/ 无法正常访问

不知该如何解决,望高手指点

------解决方案--------------------
你那样写当然不能访问了,你这还差一层呢,你应该这样写(http://127.0.0.1:81/LoadPage )!要http://127.0.0.1:81/这样访问,你主页index,应该与LoadPage放在同目录下!