app_start下的Startup.cs
app.UseCookieAuthentication(new CookieAuthenticationOptions
???????????{
???????????????AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
???????????????//LoginPath = new PathString("/Account/Login"),
???????????????LoginPath = new PathString("/Question/Question"),
???????????????// by setting following values, the auth cookie will expire after the configured amount of time (default 14 days) when user set the (IsPermanent == true) on the login
???????????????ExpireTimeSpan = new TimeSpan(int.Parse(ConfigurationManager.AppSettings["AuthSession.ExpireTimeInDays.WhenPersistent"] ?? "14"), 0, 0, 0),
???????????????SlidingExpiration = bool.Parse(ConfigurationManager.AppSettings["AuthSession.SlidingExpirationEnabled"] ?? bool.FalseString)
???????????});
??????????
修改路由配置
public class RouteConfig
???{
???????public static void RegisterRoutes(RouteCollection routes)
???????{
???????????routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
???????????//ASP.NET Web API Route Config
???????????routes.MapHttpRoute(
???????????????name: "DefaultApi",
???????????????routeTemplate: "api/{controller}/{id}",
???????????????defaults: new { id = RouteParameter.Optional }
???????????????);
???????????routes.MapRoute(
???????????????name: "Default",
???????????????url: "{controller}/{action}/{id}",
???????????????defaults: new { controller = "Question", action = "Index", id = UrlParameter.Optional }
???????????);
???????}
???}
QuestionnaireNavigationProvider
可以增加导航
public override void SetNavigation(INavigationProviderContext context)
???????{
???????????context.Manager.MainMenu
???????????????.AddItem(
???????????????????new MenuItemDefinition(
???????????????????????PageNames.Home,
???????????????????????L("HomePage"),
???????????????????????url: "",
???????????????????????icon: "home",
???????????????????????requiresAuthentication: true
???????????????????)
???????????????).AddItem(
???????????????????new MenuItemDefinition(
???????????????????????PageNames.About,
???????????????????????L("About"),
???????????????????????url: "About",
???????????????????????icon: "info"
???????????????????)
???????????????).AddItem(
???????????????????new MenuItemDefinition(
???????????????????????"Investigation",
???????????????????????L("Investigation"),
???????????????????????url: "Investigation",
???????????????????????icon: "info"
???????????????????)
???????????????);
???????}
MVC修改起始页
原文地址:https://www.cnblogs.com/Seraph12/p/8424046.html