Knowledge Management Banner

Knowledge Management Banner

Adding separate Js file to razor view


  • The jquery / javascript that is required for view can be written inline or in a separate js file. 
  • Writing script in separate file and including that file at the end of view is always the best coding practice
Step 1 ]
  • Include js file in view as shown in image below.
  • Path will vary depending on project structure and file name.

Step 2] 
  • Open web.config file located in View folder.


Step 3] 
  • Add http handler as shown in figure below
  • <add path="*.js" verb="GET, HEAD" type = "System.Web.StaticFileHandler"/>



No comments

Powered by Blogger.