-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathHomeController.cs
More file actions
113 lines (89 loc) · 2.76 KB
/
HomeController.cs
File metadata and controls
113 lines (89 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Localization;
using Microsoft.AspNetCore.Http;
using cloudscribe.Web.Navigation;
namespace NavigationDemo.Web.Controllers
{
public class HomeController : Controller
{
[NavNode(Key = "Home", ParentKey = "", Text = "Home")]
public IActionResult Index()
{
return View();
}
public IActionResult About()
{
ViewData["Message"] = "Your application description page.";
return View();
}
public IActionResult AboutMe()
{
ViewData["Message"] = "about me page.";
return View("About");
}
public IActionResult AboutCompany()
{
ViewData["Message"] = "about company page.";
return View("About");
}
public IActionResult AboutProject()
{
ViewData["Message"] = "about project page.";
return View("About");
}
public IActionResult Contact()
{
ViewData["Message"] = "Your contact page.";
return View();
}
public IActionResult HideAuth()
{
ViewData["Message"] = "Your contact page.";
return View("Contact");
}
public IActionResult HideAnon()
{
ViewData["Message"] = "Your contact page.";
return View("Contact");
}
public IActionResult Error()
{
return View("~/Views/Shared/Error.cshtml");
}
[Authorize(Roles = "Admins")]
public IActionResult Administration()
{
ViewData["Message"] = "Administrators only.";
return View();
}
[Authorize(Roles = "Admins,Members")]
public IActionResult Members()
{
ViewData["Message"] = "Members only.";
return View();
}
[HttpPost]
public IActionResult SetLanguage(string culture, string returnUrl)
{
Response.Cookies.Append(
CookieRequestCultureProvider.DefaultCookieName,
CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(culture)),
new CookieOptions { Expires = DateTimeOffset.UtcNow.AddYears(1) }
);
return LocalRedirect(returnUrl);
}
[HttpPost]
public IActionResult ClearLanguageCookie(string culture, string returnUrl)
{
Response.Cookies.Delete(
CookieRequestCultureProvider.DefaultCookieName
);
return LocalRedirect(returnUrl);
}
}
}