Does Razor needs MVC3 or can I use it only with .NET? - nvelocity

I am newbie for template engines Just I am curious is it possible to use Razor without MVC ? I want to use a template engine in .NET. I have looked at the NVelocity but razor seems more understandable to me

Well, not really. Razor view engine is built on top of ASP.Net but it doesn't depend on MVC framework.
You can use it in a console app if you wish.
Here's a good article demonstrating the use outside of MVC: http://buildstarted.com/2010/09/29/razor-view-engine-without-mvc-at-all/
and another one here from Andrew Nurse: http://vibrantcode.com/blog/2010/7/22/using-the-razor-parser-outside-of-aspnet.html

You can check out RazorEngine:
A templating engine built upon Microsoft's Razor parsing technology.
The RazorEngine allows you to use Razor syntax to build robust
templates

Related

How to use razor code in ASP.NET?

I don't know how to use the razor code in my asp.net project. I am reading this tutorial w3school , but when i write the code in my "defaul.aspx" file then it can't run. can any one please tell me that how exactly to use the razor code in ASP.NET
When you want to work with Razor in your asp.net Project, then you should create ".cshtml" file like Page.cshtml, write down all the code of Razor there. WebMatrix is a tool through which you can also create professional website of asp.net, and where you would have to handle the Razor. for further detail please see this liknk Razor in Asp.net

how can i user razor syntax in asp.net project not mvc [duplicate]

I'm liking the Razor syntax that Microsoft has developed for inline coding in their WebMatrix product (http://en.wikipedia.org/wiki/Microsoft_WebMatrix).
Now that Visual Studio SP1 has RTM'd, is it possible (and/or planned) to enable the use of Razor syntax in ASP.NET Webforms?
We (the ASP.NET team) currently have no plans to support the WebForms page model using Razor syntax. Furthermore it is unlikely that we would ever seriously consider this as the models are too different to make the two work together.
You can use Razor pages without MVC; this is called ASP.Net WebPages.
Just add .CSHTML files to a normal ASP.Net 4.0 project.
I explained how this works in my blog.
You could possibly integrate it using the RazorEngine available from Codeplex. It allows you to process razor outside of MVC. Though you don't get all the features you get from the MVC version of Razor, such as #Html and #Url and others.
I dare say that Microsoft have considered it, but there is no official word on the subject. Since you are not supposed to have C# or VB code in the ASPX file, you have to wonder about the point of adding Razor support to Web Forms. The code behind would still be a (partial) class file. You wouldn't put Razor there any more than you would put it in a class file in Web Pages or MVC. And swapping Server Controls and all that good declarative stuff for Html Helpers removes one of the key reasons for going the Web Forms route, IMO.
This really isn't that difficult to do. Working on it right now. Grab RazorEngine from CodePlex. It lets you compile Razor cshtml/vbhtml files into a class at runtime.
You can then take that class, and use it from a ASP.Net server control, inside its Render method. This is a great way to get HTML out of the body of a server control. Much, much cleaner.
Now, you can also add some methods that you can invoke from Razor. For instance, add something like RenderChild. Additionally, you could set the Server Control itself as the Model available to Razor. You could then invoke into the server control. Including doing something like grabbing one of it's child controls and invoking Render.

ASP.NET - Component licensing and Razor

If I have a library that uses .NET component licensing (such as DevArt's dotconnect) with the new Razor view engine, do I need to produce a special App_Licenses.dll for Razor to work?
I can see you already got the official answer in their forums:
http://www.devart.com/forums/viewtopic.php?t=20815&sid=0cdf252bc73af673032cccc6f7443659
If ASP.NET source files will be
compiled at server on user request,
you should create a special assembly
App_Licenses.dll in the Bin directory
of your site:
http://www.devart.com/dotconnect/universal/docs/licensing.html#asp.
We have not tested our product with
Razor view engine. If you encounter
any difficulties, please contact us.
Based on that answer, I think you might not need it if you pre-compile your Razor views
See Compile Views in ASP.NET MVC (and Notes on Building Razor Views).

Using MS Ajax Minfier 4.0 for Asp.Net MVC 2.0?

I am planning to use MS Ajax Minifier with Asp.Net MVC 2.0 for handling the Js and Css files. Does anyone has experience with MS Ajax Minifier? I have following questions regarding this.
Is it the best way to use JS/CSS files in Asp.Net MVC or is there a better way. E.g. YUI Compressor, Telerik Extension for MVC?
As I understand we can use this to convert SomeFile.js to SomeFile.min.js at the build time. However In my mvc Views I still have the Script reference pointing to SomeFile.js. How does the browser will pick the SomeFile.min.js file?
It's one possibility to use. The integration when building is a nice asset and it has hypercrunching.
You must use the SomeFile.min.js in your script reference. But in Visual Studio you can have an uncompressed file with this name SomeFile-vsdoc.js for intellisense coding (in which you can also use xml comments which will be picked up by VS.
Another approach would be to use SquishIt.
Grz, Kris.

ASP.NET MVC without ASP.NET?

As far as I know, ASP.NET MVC leverages a lot of the features of ASP.NET Web Forms, one of these services is how to get the Html response from the template .aspx file (the view). Can asp.net mvc leverages any other platform to generate html over template files (something like PHP for example)?
EDIT: There is NO use case for this, just curiosity!
Yes, it can! The aspx model is just one of the view template mechanisms. There are others - you can even write your own. The key here is IViewEngine, with WebFormViewEngine being the aspx/ascx provider. ASP.NET MVC In Action covers some of this in chapter 6 "Customizing & Extending the ASP.NET MVC Framework".
you can use other ViewEngines
Spark
NHaml

Resources