Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I have a global razor @helper outside of App_Code?

Tags:

The question is simple as stated in the title: Is there a way of having razor helpers outside of 'App_Code'?

Example ( HtmlEx.cshtml file ):

@helper Script(string fileName, UrlHelper url) { <script src="@url.Content("~/Scripts/" + fileName)" type="text/javascript"></script>  } 

I ask this because I don't really have anything else to put in App_Code; I want to structure my project a bit different.

Thanks.

UPDATE: I don't want any other type of extensions. I am interested in only pure razor helpers as Scott is speaking about here: http://weblogs.asp.net/scottgu/archive/2011/05/12/asp-net-mvc-3-and-the-helper-syntax-within-razor.aspx

like image 633
Learner Avatar asked May 19 '12 12:05

Learner


People also ask

What is razor used for in asp net?

What is Razor? Razor is a markup syntax that lets you embed server-based code (Visual Basic and C#) into web pages. Server-based code can create dynamic web content on the fly, while a web page is written to the browser.

What is razor in asp net core?

Razor Pages can make coding page-focused scenarios easier and more productive than using controllers and views. If you're looking for a tutorial that uses the Model-View-Controller approach, see Get started with ASP.NET Core MVC. This document provides an introduction to Razor Pages. It's not a step by step tutorial.

What is razor in ASP NET MVC?

Razor is a markup syntax that lets you embed server-based code into web pages using C# and VB.Net. It is not a programming language. It is a server side markup language. Razor has no ties to ASP.NET MVC because Razor is a general-purpose templating engine. You can use it anywhere to generate output like HTML.


1 Answers

The question is simple as stated in the title: Is there a way of having razor helpers outside of 'App_Code'?

No, there isn't.

like image 170
Darin Dimitrov Avatar answered Oct 27 '22 00:10

Darin Dimitrov