MVC5 razor templates client server - c#

Is it possible to use Razor for client and server side templates for MVC5? I now have to refactor a lot of my project to using AJAX, and client side template rendering. I was hoping to find something so that I won't have two separate template files for the same view. All my views are now made in Razor.
The project is using MVC5 and the latest Razor (version3)
Thanks in advance!

I doing the same investigation. Razor template rendering in javascript would be the ideal soluion...
Maybe this could be the good enter point
http://www.fidelitydesign.net/?p=375
https://github.com/kirbysayshi/vash
I also looking for template engine which could work for both MVC5 server and client side. I found jade template engine and Spark framework for asp. Spark can undestnd Jade sintax and javascript has Jade template engine. It seams like I found the solution but Spark framework stop developing on mvc3 stage... the same thing for nustache. It is annoying stopper.

Related

Should I be mixing .cshtml files and .razor files in my .NET 6 project?

I'm not trying to specifically create a Blazor Web application, rather I'm rewriting an old ASP.Net Framework application in Razor and the newest .NET (currently .NET 6). I've created a .razor component for my Footer that is going to appear in all of my pages. I'm unable to get it to display, I currently have this:
#section Footer {
<component type="typeof(NewProject.Pages.Footer)" render-mode="Static"/>
}
But then I have read that .razor files are supposed to be used in Blazor Web applications and they should be used instead of .cshtml files. I'm trying to stick to Razor pages and MVVM instead of MVC, and I'm still very new to both Razor and Blazor, and before I get too much further into this, I would like to know if I should instead create the Footer as a Partial View instead of a Blazor component. These are the files I've created.
Microsoft's answer, apparently, is a big yes. The default Blazor project uses cshtml as the foundation for the site, as well as for the scaffolded Identity system, and razor for everything else.
I know you're not planning to use Blazor, but the above indicates to me that they're meant to co-exist.

How to organize multilingual URLs in ASP.Net Core Razor Pages?

ASP.NET Core 2.2.0
I'm looking for language-based urls in ASP.NET Core. Found a lot of examples online for .NET Core MVC, but can't get it working in Razor Pages.
What I want to achieve is:
domain.com/informatie -> link to the 'information' page in default language (Dutch for me)
domain.com/en/information -> link to same the same page in English
Therefor I need 2 features:
Recognize the language in the url, or set default language when language-tag is not provided
Translate the names of my Pagemodels
I will write a custom method for translating the content.
Best fitting example
I found 2 examples that do almost the same I want, but they are using MVC:
ASP.NET Core: Simple localization and language based URL-s
Localized routing using ASP.NET Core MVC 2
The second one looks great, I tried to rewrite it for Razor Pages, but got stuck on the LocalizationController.cs (since I'm not using a controller, but a Pagemodel) CultureActionLinkTagHelper.cs (I use the asp-page attribute).
Is there anybody who has fixed this in Razor Pages and who would like to share the code? Or anybody who can help me through?
You need to build your application considering globalization/localization.
Here is the official documentation from Microsoft.
You may find this tutorial for Developing Multicultural Web Application helpful, it is for DotNetCore 2.1 Razor Pages, but it is valid for 2.2 as well.
Additionally, her is a sample project for localizing razor pages in GitHub

Simplified "Razor-Only" website?

I have a website I want to make using the Razor template engine, however it really only has one simple page with a basic AJAX form in it. Having a full-blown MVC Web Application seems like a massive overkill for this, but I don't want to have to use something like PHP. Can I use Razor in a 'PHP-like' manner (i.e. one or two .cshtml/.vbhtml pages I can make requests to, in a similar function to how you make requests to .php pages)?
This will be hosted on IIS 8, if that'll help.
You can use razor with ASP.NET Websites (not web projects).
To do this go to File > New Web Site... and pick one of the templates that supports razor.
http://msdn.microsoft.com/en-us/library/gg606533%28v=vs.100%29.aspx
Gives more depth, however, you might be able to skip the first step "Installing the ASP.NET Razor Tools" if you already have it installed.

Is there any c# web framework like Django or Ruby on Rails?

Is there any c# web framework like Django or Ruby on Rails? I know ASP.net MVC, but is seems not like Django, still got .aspx page and server side code on .aspx pages.
Is there some other c# web framework like django, pure html templates and c# code at back end side?
Thanks
try MVC3. It has scaffolding and Razor View Engine which is much better and more htmlish than aspx

What are the options available for asp.net mvc paging with jQuery?

As I know in current Asp.Net MVC3, there is a component available named WebGrid and in jQuery there is component available named jqgrid. Can anybody show a comparison of boh these components in terms of features and which is easy to setup and get going.
Also if there are any options for grid in jquery suggest them too. Few tutorials links etc. too may be helpful. I am complete beginner in Asp.Net MVC3.
check these out :
Using jQuery Grid With ASP.NET MVC
ASP.net MVC JQuery Json and Paging
Get the free telerik MVC open source controls . Is the easiest and most full featured one out there.

Categories