Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebMatrix Razor pages and global using statements

How can I setup global usings for all my .cshtml pages in WebMatrix Razor context (not ASP.NET MVC Razor)?

So instead of putting @using System.Web.Optimization on top of each .cshtml file where I need to include @Scripts.Render() I would put it into one single place instead.

like image 212
Grief Coder Avatar asked Oct 06 '22 13:10

Grief Coder


1 Answers

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="true" />
  </appSettings>
  <system.web.webPages.razor>
    <pages pageBaseType="System.Web.WebPages.WebPage">
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>
</configuration>

See also: Building single-page app with AngularJS and ASP.NET MVC 4

like image 76
Konstantin Tarkus Avatar answered Oct 10 '22 03:10

Konstantin Tarkus