2

I do have some text(template), which looks like "Hello @FirstName, Welcome to @Address". The original plan was to put this text file in a view-bag and pass it through razor and it will do the job.

Now, The problem that I am facing is that my team wants this transformation to be handled by a Service, So there is no controller and there is no view here BUT there is a need to use Razor view engine's capability to replace all @ with server variables.

This sounded weird to me as well but is there any way that I can extract this capability of Razor view in a way that I can use this functionality in a restful service rather than sending this data to a .cshtml file?

2 Answers 2

2

This is possible indeed.

Rick Strahl blogged about hosting the Razor Engine in non-web applications.

And of course, this has been asked here before.

Sign up to request clarification or add additional context in comments.

4 Comments

Actually, I visited the blog and I liked it but he does not mention anywhere that where did he get reference for RazorTemplateBase? i have no idea if I need to download a package or something?
@Californicated - He does mention it, under the "Installing The Razor Template Engine" heading. Taken from microsoft.com/web/gallery/install.aspx
The only razor app in the library that I can see is razorC.Net. is it the one?
Actually, I came across something called @razorEngineon following URL:razorengine.codeplex.com/…. It's awesome and it worked for me.
1

Yes, it is possbible. The necessary steps to do that is described here: Razor View Engine without MVC at all.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.