Installation
ASP.net Core
1) Download MinSetupCoreDemo to use as an example, and copy the binaries (dll/js/css) files from it. Binaries can also be copied from here: trial download. 2) Copy from the libs folderOmu.AwesomeMvc.dll/xml,
Omu.Awem.dll/xmland put into your
libsfolder, copy
wwwroot/lib/aweand put in your
wwwroot/lib/folder. 3) Add nuget package reference to
Newtonsoft.Json13 or higher (if you don't have it already). 4) Add Reference to
Omu.AwesomeMvc.dlland
Omu.Awem.dll(right click your project -> Add -> Project Reference -> Browse -> Select dlls -> OK). 5) Add the following to
Views\_ViewImports.cshtml:
@using Omu.AwesomeMvc6) In
@using Omu.Awem.Helpers
_Layout.cshtmladd references to jQuery (or aquery) and Awesome css and js files after declare the
@Html.Awe().Init()html helper, example:
<link href="~/lib/awe/css/themes/mat/AwesomeMvc.css" rel="stylesheet" type="text/css"/>Now you can try adding
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="~/lib/awe/js/AwesomeMvc.js" asp-append-version="true"></script>
<script src="~/lib/awe/js/awem.js" asp-append-version="true"></script>
<script src="~/lib/awe/js/aweUtils.js" asp-append-version="true"></script>
@Html.Awe().Init()
@Html.Awe().Button().Text("hi").OnClick("awem.notif('hi')")in your
Index.cshtmlto test the installation. 7) In
Program.csadd or merge the following (this is for the metadata attributes):
var provider = new AweMetaProvider();If you're using
builder.Services.AddControllersWithViews(o => o.ModelMetadataDetailsProviders.Add(provider));
Startup.cs, in
Startup.cs -> ConfigureServices:
var provider = new AweMetaProvider();Optional steps (utils used in our grid crud demos): 8) From the MinSetupCoreDemo copy the
services.AddMvc(o =>
{
o.ModelMetadataDetailsProviders.Add(provider);
});
Utilsand
Helpersfolder, and
ViewModel/Input/DeleteConfirmInput.cs, edit the namespaces in the copied
.csfiles to match your project. 9) Copy the using statements for the helpers and utils from
Views\_ViewImports.cshtml, change the namespace to match your project, the result should look like this:
@using Omu.AwesomeMvc10) Copy
@using Omu.Awem.Helpers
@using YourAppNamespace.Helpers.Awesome
@using YourAppNamespace.Utils.Awesome
@using YourAppNamespace.ViewModels.Input
Shared/Delete.cshtml,
Shared/_FieldLayout.cshtml, and
Shared/EditorTemplatesfolder.
ASP.net Core _Layout.cshtml example
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - ASP.net Core Awesome min setup demo</title>
<link href="~/lib/awe/css/themes/mat/AwesomeMvc.css" rel="stylesheet" type="text/css"/>
</head>
<body class="mat">
<div class="main">
@RenderBody()
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="~/lib/awe/js/AwesomeMvc.js" type="text/javascript"></script>
<script src="~/lib/awe/js/awem.js" type="text/javascript"></script>
<script src="~/lib/awe/js/aweUtils.js" type="text/javascript"></script>
@Html.Awe().Init()
</body>
</html>
Content Security Policy (CSP) Setup
To use ASP.NET Core Awesome in an application with a Content Security Policy (CSP), additional configuration is required to ensure compatibility with CSP restrictions. Download CSPMinSetupCoreDemo for an example solution. 1) InProgram.cs, disable inline styles and JavaScript by setting:
Settings.UseInlineStyleAndJS = false;2) In
Views/Shared/_Layout.cshtml, instead of
@Html.Awe().Init()use:
@Html.Awe().InitTag()Then, reference the
aweinit.jsscript. See the example
_Layout.cshtmlbelow for details.
Example _Layout.cshtml for CSP
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Security-Policy" content="
default-src 'self';
script-src 'self';
style-src 'self' https://fonts.googleapis.com;
font-src 'self' https://fonts.gstatic.com;
object-src 'none';
img-src 'self';
">
<title>@ViewData["Title"] - ASP.NET Core Awesome min setup demo</title>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<link href="~/lib/awe/css/themes/mat/AwesomeMvc.css" rel="stylesheet" type="text/css"/>
<link href="~/css/site.css" rel="stylesheet" type="text/css" />
</head>
<body class="mat">
<div class="main">
@RenderBody()
</div>
@Html.Awe().InitTag()
<script src="~/js/jquery-3.7.1.js"></script>
<script src="~/lib/awe/js/AwesomeMvc.js" type="text/javascript"></script>
<script src="~/lib/awe/js/awem.js" type="text/javascript"></script>
<script src="~/lib/awe/js/aweUtils.js" type="text/javascript"></script>
<script src="~/lib/awe/js/aweinit.js" type="text/javascript"></script>
</body>
</html>
ASP.net MVC 5
1) Download the MinSetupDemo, 2) Copy from the libs folderOmu.AwesomeMvc.dll/xml,
Omu.Awem.dll/xmland put into your
libsfolder, copy
lib/aweand put in your
/lib/folder. 3) Reference
Omu.AwesomeMvc.dlland
Omu.Awem.dllin your web project. 4) Open
Views\web.configand in
<system.web.webPages.razor> -> <pages> -> <namespaces>add:
<add namespace="Omu.AwesomeMvc" />If you're using aspx, ascx views you would add the same in the main web.config in
<add namespace="Omu.Awem.Helpers" />
<system.web> -> <pages> -> <namespaces>5) Open
_Layout.cshtmland copy the references to the js and css files ( keep the same order ), and the call to
@Html.Awe().Init(). Now you can try adding
@Html.Awe().Button().Text("hi").OnClick("awem.notif('awesome')")in your
Index.cshtmlto test the installation. Optional (utils used in our grid crud demos): 6) Copy the
Utilsand
Helpersfolder, and
ViewModel/Input/DeleteConfirmInput.cs, include them in your project, edit the namespaces in the copied cs files to match your project. 7) add the new namespaces to the
Views\web.config
<add namespace="YourAppNamespace.Utils" />8) Copy the`Views/Shared/EditorTemplates` folder and
<add namespace="YourAppNamespace.Helpers.Awesome" />
Views/Shared/Delete.cshtml.
ASP.net MVC 5 _Layout.cshtml example
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewBag.Title - ASP.net MVC Awesome MVC5 min setup demo</title>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<link href="@Url.Content("~/lib/awe/css/themes/mat/AwesomeMvc.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/site.css")" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="main">
@RenderBody()
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="@Url.Content("~/lib/awe/js/AwesomeMvc.js")" type="text/javascript"></script>
<script src="@Url.Content("~/lib/awe/js/awem.js")" type="text/javascript"></script>
<script src="@Url.Content("~/lib/awe/js/aweUtils.js")" type="text/javascript"></script>
@Html.Awe().Init()
</body>
</html>
Comments