c# - render unbundled assets for admin user role -


Is it possible for users to present unprotected scripts and styles unhandled and in the role of "Admin"?

I searched and found how to disable bundling

  bundletable.acceptoptimism = ...  

and minification < / P>

  foreach (bundle bundle in bundle) {bundle. Transforms. Clear (); }  

in global.asax.cs Application_Start , but I think this argument must be per-user, not every instance of the application, so it should not only be running the application Upon launching.

First of all, no style or script included in the bundle config will be loaded until it is on the script Call by calling.Renderer () or Styles.Renderer () Methods By default, these methods are called from _Layout.schtml page (View / Share). @ Scripts.Renderers ("~ / / bundle / jquery") @

  @ styles.crt ("~ / content / css") @ scripts. Renderers ("~ / bundle / modern") @ scripts Render ("~ / bundle / bootstrap")  

Creating a separate layout page for the admin area and loading required script and style will be a better option.

The same method, it is also possible to load them from any .cshtml file (view) using scripts.render (). In this case, this will be done,

  @ {if user.IsInRole ("Admin")) // Update this script with this script as necessary scripts. Update this part with the path of bundles required for render ("~ / bundle / jquery")} other {// scripts. Renders ("~ / bundles / jquery") @ scripts The above snippet can be added to either _Layout page or any other page.  

And if requirement is to add any unhandled code, just use the script tag. Which will look like this:

  @ {if user (insinol ("admin")) {// script or style files are required} other {// include unbundle and non-proliferation scripts & Lt; Script type = "text / javascript" src = "~ / scripts / jquery.validate.js" & gt; & Lt; / Script & gt; }}  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -