►
From YouTube: Sebastien Ros on ASP.NET Core MVC Resource Management
Description
Shows how to manage resources like scripts and styles in ASP.NET Core MVC using the Orchard.ResourceManagement package (available for use independently as a NuGet package. This allows you to do some advanced things like inject scripts and styles from View Components and Partials, prevent duplicate registrations, and define resource dependencies.
Code for this episode is available here: https://github.com/OrchardCMS/Orchard2/tree/master/src/OrchardCore/Orchard.ResourceManagement
A
B
Show
you
how
to
manage
your
resources
like
scripts
and
styles
in
a
spinet
call
NBC,
ok,
so
what
does
it
mean?
It
means
that
when
you
have
an
MVC
app
with
views
and
view
components
and
partial
views-
and
you
want
to
inject
some
scripts
and
styles
and
other
assets
in
your
views-
you
don't
really
have
many
choices.
You
just
have
to
change
your
layout,
but
what
you
might
want
is
to
be
able
to
define
those
dependencies
on
the
scripts
and
size
from
the
components
themselves.
B
B
It's
published
independently,
so
here's
a
simple
package,
so
let
me
show
you
how
to
use
it
by
just
opening.
Visuals
Yoda
sees
the
standard
template,
MVC
template
from
a
spirit
call
anything,
and
what
I
will
do
first
is
reference
this
package
from
the
gate,
so
I
will
call
it
its
orchard
resource
management
here
and
I
will
install
it
and
then
for
in
my
started,
like
any
other,
a
Mexico
I
select
call
package.
I
will
just
do
add.
A
B
B
Management,
okay,
I
just
saved,
and
now,
if
I
go
in
the
view
like
the
about
page
or
first,
maybe
let's
see
the
layout
the
layout.
Let's
see
what
new
toggle
pearls
I
have.
So
you
see
these
purple
things
the
auto
Gabor's.
So
let
me
open
the
layout
file
and
if
I
type
resources
I
see
it
provides
a
mechanism,
so
I
will
type,
and
here
I
can
inject
some
resources
for
footer
header,
head,
scrapes
and
so
on.
B
So
here,
I
will
just
start
with
head
scripts
to
inject
some
scripts
in
the
header
of
my
page,
but
I
haven't
used
or
define
or
injected
anything
in
my
resources
for
my
script.
So
the
idea
is
that,
from
the
view,
for
instance,
about
I
will
be
able
to
say
that
this
view
requires
some
custom
script,
so
I
will
do
a
script
and
SP
and
now
I
can
do
SRC.
For
instance,
my
script
Dodge's,
ok,
ok
and
it
recognizes
it
as
a
toggle
/,
because
there
is
a
is
P.
A
B
B
Now
the
views
can
inject
scripts
directly
in
the
layout
or
wherever
I
want
to
render
them
views
and
other
components.
But
I
can
do
that
with
scripts
and
I
can
also
do
that
with
tiles
because
sometimes
create
a
view,
and
this
view
is
a
style
not
the
others.
So
I
can
just
say
style
same
thing:
SLC
my
style,
dot,
CSS
I,
don't
need
to
add
foot
or
wire
because
does
not.
A
B
Right
after
there
I
can
do
stylesheet,
okay
and
if
I
go
to
the
view
and
test
five
now
I
have
my
Styles
here
and
I.
Have
my
scripts
at
the
bottom
and
any
component
which
takes
part
in
to
the
rendering
of
this
page
can
do
the
same
thing.
So,
for
instance,
if
I
create
a
partial
view,
I
will
call
it
a
I
will
clear
this
thing
and
I
will
just
say
I
from
hey
and
in
my
view,
I
will
render
this
partial
view.
So
I
will
do
partial.
B
B
A
B
What
you'd
want
exactly
other
example?
Let's
say
you
want
to
enhance
your
SEO
so
from
a
partial
you
will
say:
I
want
to
render
meta
tag
and
you
can
say
meta
tag.
Espy
name
equals
keywords,
for
instance,
because
this
partial
adds
some
stuff
that
you
wanted
keywords.
You
will
do.
Content
equals
tag,
a
okay,
okay,.
A
B
B
A
B
Gave
three
times
because
I
have
three
partials
yeah
here
it's
static,
so
it
doesn't
make
sense
that
they
might
be
dynamic
from
content.
Okay.
So
that's
really
so
this
is
cool
to
inject
stuff,
but
it's
even
better
when
you
have
libraries
which
will
predefined
these
scripts
for
you,
so
you
can
have
packages
which
we,
for
instance,
define
what
angular
is
and
where
it
is,
and
what
dependency
does.
B
So,
if
I
go
here
and
drag
and
drop
this
class
in
my
project,
this
either
service,
okay,
that
implements
I
resource
manifest
provider
and
defines
a
manifest
for
your
resources
that
says,
I
will
define
the
script
named
angular,
just
the
name,
the
CDN
location
is
there.
The
version
is
that
you
can
also
define
dependencies.
You
can
define
a
Skien
integrity
to
check
for
a
checksum
when
it's
donal
it'll
define
many
metadata,
but
here
by
just
doing
that
and
registering
it
in
as
a
service
in
my
startup.
B
B
A
B
A
B
And
you
can
also
suppose
dependencies.
So
if
angular
depends
on
jQuery,
you
can
modify
say
that
angular
depends
on
degree
and
when
you
say
I
want
a
grow.
If
we
also
include
your
in
the
correct
order
and
it
suppose
vision,
so
you
could
say
angular
1,
6
1
depends
on
jQuery
2,
so
it
will
just
be
the
one
you
want
and
not
another
one,
the
one
a
little
better.
Okay,
so
yeah
wow.