ASP.NET Core 2.1 MVC react.js 模板和标识
ASP.NET Core 2.1 MVC react.js template and identity
是否可以在带有 react.js 的 SPA 项目中使用 Microsoft.AspNetCore.Identities
? Visual Studio 2017 中的模板仅提供无身份验证选项。如果不能用Microsoft.AspNetCore.Identity
,还有什么选择?谢谢
使用ReactJs.Net - https://reactjs.net.
[Authorize]
public async Task<IActionResult> Index()
{
var result = await drw.GetAllCompanysAsync();
return View(result);
}
可见
@model IEnumerable<Company>
@{
ViewBag.Title = "Абоненты";
}
Html.React("Application", new
{
initialData = Model,
url = Url.Action("GetCompanyHeatPerDay", ,
submitUrl = Url.Action("AddComment"),
}, containerId: "app")
<script crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/react/16.4.1/umd/react.development.js"></script>
<script crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.4.1/umd/react-dom.development.js"></script>
<script crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/prop-types/15.6.2/prop-types.min.js"></script>
<script src="@Url.Content("~/js/app.jsx")"></script>
Html.ReactInitJavaScript()
app.jsx
中的所有视图逻辑
带有 AspNetCore.Identities 的 IdentityServer4 是 SPA 应用程序的解决方案。
是否可以在带有 react.js 的 SPA 项目中使用 Microsoft.AspNetCore.Identities
? Visual Studio 2017 中的模板仅提供无身份验证选项。如果不能用Microsoft.AspNetCore.Identity
,还有什么选择?谢谢
使用ReactJs.Net - https://reactjs.net.
[Authorize]
public async Task<IActionResult> Index()
{
var result = await drw.GetAllCompanysAsync();
return View(result);
}
可见
@model IEnumerable<Company>
@{
ViewBag.Title = "Абоненты";
}
Html.React("Application", new
{
initialData = Model,
url = Url.Action("GetCompanyHeatPerDay", ,
submitUrl = Url.Action("AddComment"),
}, containerId: "app")
<script crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/react/16.4.1/umd/react.development.js"></script>
<script crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.4.1/umd/react-dom.development.js"></script>
<script crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/prop-types/15.6.2/prop-types.min.js"></script>
<script src="@Url.Content("~/js/app.jsx")"></script>
Html.ReactInitJavaScript()
app.jsx
中的所有视图逻辑带有 AspNetCore.Identities 的 IdentityServer4 是 SPA 应用程序的解决方案。