Giter Site home page Giter Site logo

telerik / razor-converter Goto Github PK

View Code? Open in Web Editor NEW
238.0 27.0 62.0 388 KB

Tool for converting WebForms Views to Razor (C# Only)

Home Page: http://blogs.telerik.com/blogs/posts/11-01-19/webforms_to_razor_view_converter_tool.aspx

License: MIT License

C# 75.38% HTML 24.62%

razor-converter's Introduction

The razor-converter is a simple tool for converting Microsoft® ASP.NET MVC WebForms Views to the new Razor syntax. It was initially developed by the Telerik ASP.NET MVC team for internal use, but it now lives its own life on GitHub.

Known limitations:

  • The tool only works with views and does not deal with the project structure and master pages.
  • Expressions in script tags are not converted
  • Due to the differences between the view engines the automatic conversion will sometimes fail or produce incorrect results. See the integration tests for specific scenarios that are not covered.

For general tips on converting WebForms Views to Razor Views, see these blog posts:

Help specific to the Telerik Extensions for ASP.NET MVC

Command line usage:

aspx2razor <input-directory> [output-directory] [options]

Options: -r: Convert directories and their contents recursively (Contributed by Jeffrey T. Fritz)

A file with cshtml extension will be created for each input file. Existing files will be OVERWRITTEN, so you must be very careful.

razor-converter's People

Contributors

csharpfritz avatar gyoshev avatar miaojiuchen avatar pamartinez avatar sebnilsson avatar tsvetomir avatar vongruenigen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

razor-converter's Issues

Whitespace preservation

Another small issue.

<span class="annotation">(<%: tag.Count %>)</span>

...became something like...

<span class="annotation">(@tag.Count )</span>

Note the space before the closing parenthesis? This changes the way the view looks.

Variables in script tags

First off, thanks for the great tool!

Found a bug though:
Assume this code:

  <script>
       var x = '<%= Url.Action("index") %>';
  </script>

The converter doesn't convert it...

Issues with running

Hi,

Can some explain me the exact steps to run this code. I have to convert the default menu structure to Razor view.

Thanks in advance.

Moves File Into Incorrect Directory

I have a file - Views/Foo/Edit.aspx and a another file Views/Foo/EditorTemplates/Bar.ascx

When I run aspx2razor against this folder, the Edit.aspx remains, and a new file Edit.cshtml is placed into the Views/Foo/EditorTemplates/ directory.

May I be doing something incorrectly? I've attempted this with the -r switch and without the -r switch. Thanks

Visual Studio 2017 compatibility

Hello,
Have u tried compiling it for VS2017 or have you just made a publish for this IDE?
I need to convert a quite huge project from webform to razor

Thanks

Ternary operators

Hi,

I found that the converter systhematically missed ternary operator in ASPX.

Here is a source fragment

<th align="center" style="width: 12%" class="<%=tableWrapper.Column == "value" ? "selected" : "" %>">

Here is how it gets converted

<th align="center" style="width: 12%" class="@tableWrapper.Column == "value" ? "selected" : """>

Here is how it's supposed to work

<th align="center" style="width: 12%" class="@(tableWrapper.Column == "value" ? "selected" : "")">

Notice the parentheses wrapping the @ expression containing the ternary.

I fixed them all manually. I hope in a future release this will be handled correctly by the tool. Nice work, anyway!

Please add this to readme:

If you get this error "Unhandled Exception: System.InvalidOperationException: Can only add child notes implementing IWebFormsContentNode" - remove asp.net user controls and "register tagprefix" directive from the aspx page before converting.

Server comments

Thanks for this great tool. One issue I found was that my server comments were completely removed during the conversion.

<%-- server comment --%>

...should be converted to...

@* server comment *@

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.