Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Basic .NET (VB.NET) support in ASP.NET Core #2738

Closed
reduckted opened this issue Jan 3, 2018 · 91 comments
Closed

Visual Basic .NET (VB.NET) support in ASP.NET Core #2738

reduckted opened this issue Jan 3, 2018 · 91 comments
Assignees
Milestone

Comments

@reduckted
Copy link
Contributor

reduckted commented Jan 3, 2018

There have been many questions asked about VB.NET support in ASP.NET Core over the past few years. If you follow them, they all lead to dead-ends - either closed with no real response, or they're moved to other repositories that are unrelated to ASP.NET Core (such as somewhere in the dotnet organization).

Over that time, there's been talk of supporting VB. It's completely understandable that ASP.NET Core didn't support VB from the outset. The project was going through a lot of rapid change, so it made sense to focus on C# initially and add support for other languages later. But the idea of supporting VB seemed to get lost along the way.

Here's a brief timeline:

Dec 16, 2014:

We plan to have extensibility points so other languages like VB, F#, etc can be added via the form of a support package or such.
#236 (comment)

Apr 25, 2015:

Hey everyone, good news! We've announced plans to support VB in ASP.NET 5 / DNX!
#236 (comment)

We are excited today to announce that ASP.NET 5 will have full support with Visual Basic (both tooling and runtime – including cross platform runtime support).
https://blogs.msdn.microsoft.com/webdev/2015/04/24/making-it-better-asp-net-with-visual-basic-14/

Nov 19, 2016:
VB Support disappears from the roadmap:

 |1.0.4|Feb 2017|
 |1.2|Q2 2017|
 
-## Future Work
-
-Visual Basic support.
-
 <em><sup>*</sup> References to yearly quarters (Q1, Q2, Q3, Q4) are calendar-based</em>

https://github.com/aspnet/Home/wiki/Roadmap/_compare/2138fe4ff8a437e8edefc333189aaa8d9b5afb6a...b49bda1f8f40975b39d14d199a9ddac0a2beb45e

Dec 12, 2017:

there are no plans to add a VB template for ASP.NET Core
#2305 (comment)

VB support seems to have gone from

"It doesn't work yet, but we plan to allow VB"

to

"There will be full support for VB!"

to

"VB is not supported, but shhh, don't tell anyone".

So my first question is:

What happened and why was there no announcement or discussion with the community about this?

It seems strange to go from announcing support for VB.NET in ASP.NET Core in an official blog post, to not supporting it at all without any feedback. Was there any announcement about this? If there was, it certainly wasn't widely published.

My next, and more important question is:

What can the VB community do to help add support for VB.NET to ASP.NET Core?

Are there project templates that we can write?
Are there code generators that we can implement?
What can we do make ASP.NET Core as awesome for VB developers as it is for C# developers?


I've thrown together a simple ASP.NET Core app (link deleted because the repo is out of date) in VB by creating a .NET Core console application, editing the project file and copying the classes generated from the ASP.NET Core C# template. It works fine, and even though it's only very basic, I can't see any reason why VB.NET cannot be supported.

@muratg
Copy link
Contributor

muratg commented Jan 3, 2018

cc @DamianEdwards

@hishamco
Copy link
Member

hishamco commented Jan 3, 2018

I logged an issue long time back to use VB alongside with .cshtml in Razor repo, since then I didn't see any action 😟.
Few weeks ago I saw a great example from @DamianEdwards that demonstrate a hyprid VB ASP.NET Core application here

@Eilon Eilon added this to the Discussions milestone Jan 4, 2018
@tb-mtg
Copy link

tb-mtg commented Jan 11, 2018

In addition to @reduckted excellent summation, Microsoft's documentation for Razor syntax for ASP.NET Core (as at 2017-10-18) still has numerous references to Visual Basic and using .vbhtml files:

This restriction doesn't apply to .vbhtml Razor files because Visual Basic syntax places parentheses around generic type parameters instead of brackets.

However ScottAddie@MSFT had posted a comment on 2017-07-21:

ASP.NET Core doesn't yet support VB.NET. You'll need to stick with ASP.NET proper for now.

So is Visual Basic/vb.net/.vbhtml files going to be included in .Net Core? And If so when??

@brunojuliao
Copy link

How can we help to make this support happen? I would love to see VB.Net and F# support!

@Eilon
Copy link
Member

Eilon commented Jan 18, 2018

I sent a PR to remove the VBHTML references from the ASP.NET Core docs: dotnet/AspNetCore.Docs#5201

There are currently no plans to introduce VBHTML support to ASP.NET Core.

We do have F# templates for ASP.NET Core, which are installed as part of the .NET Core SDK.

@reduckted
Copy link
Contributor Author

@Eilon There are currently no plans to introduce VBHTML support to ASP.NET Core.

Personally, I'm not concerned about VBHTML support because I don't use Razor pages, and don't intend to. As mentioned by @AnthonyDGreen (dotnet/vblang#238 (comment)), it doesn't make sense to add VB support to it because it was rarely used in MVC 5, and, I imagine, would take a very large amount of work for not a lot of gain.

@Eilon We do have F# templates for ASP.NET Core, which are installed as part of the .NET Core SDK.

OK, but I'm not really sure what your point is here. If anything, doesn't this just reinforce the fact that there should be VB templates as well?

Weren't the F# templates created by the F# community? If the team at Microsoft won't create VB templates, then why can't the VB templates be created by the VB community?

@Eilon
Copy link
Member

Eilon commented Jan 18, 2018

@reduckted the question comes down to the demand for it and the cost of it - both the initial cost and the ongoing cost. The demand has been very low, as noted earlier. The cost to create an initial set of templates might not be much, but someone has to maintain them. With F# we have people at Microsoft who are committed to maintaining them. We don't have any such people for VB at this time.

Also, one limitation with the F# templates is that they focus more on the API side of things; that is, no Razor or CSHTML (because there's no FSHTML). With VB users my guess is that most users using VB would be expecting a VBHTML experience for MVC, and the cost of producing that is enormous - months and months of work. So, it isn't clear to me that adding limited VB templates would be particularly valuable.

@reduckted
Copy link
Contributor Author

@Eilon With VB users my guess is that most users using VB would be expecting a VBHTML experience for MVC...

You may want to speak to @AnthonyDGreen, because that's exactly the opposite of what he has said in the comment that I previously linked to (dotnet/vblang#238 (comment)). I'll quote it this time (emphasis is mine):

The .vbhtml razor engine from MVC 5 wasn't ported to Core primarily because less than 1% of all VB web projects used it after 5 versions.

@Eilon
Copy link
Member

Eilon commented Jan 19, 2018

@reduckted - interesting, that is news to me. I'm thinking back to Web Forms days, which was initially designed with concepts that were familiar to VB developers (VB6, specifically), and Web Forms was very HTML-centric (sorta), so that led me to think that VBHTML would be most interesting to that group of people. Then again, that's ~15 year old anec-data 😄

BTW to be clear, we haven't said that we're never going to do it - just that it isn't currently in any plans.

@hishamco
Copy link
Member

I'm a VB fan 😄, which I expect .vbhtml to be out-of-the-box, the hybrid approach that I mentioned before is not enough for all the VB guys, but It's fine is some cases. My question is some re-implement the Razor to emit VB instead of C# is that gonna work, or the MVC is tightly coupled on the cshtml C#?

@KathleenDollard
Copy link

@hishamco Unfortunately Razor was implemented so that VB and C# were separate paths. I've talked to a few people involved and it's quite a large project.

@tb-mtg
Copy link

tb-mtg commented Feb 4, 2018

@KathleenDollard There are other .NET Core projects that support custom ViewEngines for .pug & .md file types.

Surely we can make it work for .vbhtml razorpages files using a .vbproj with <Project Sdk="Microsoft.NET.Sdk.Web">.

@KathleenDollard
Copy link

@tb-mtg It's all open source if you want to explore it and see what those projects did. The folks that wrote it told me it was a big effort. The size of the effort and the exceedingly low adoption of vbhtml in earlier versions of MVC make it a hard sell.

@hishamco
Copy link
Member

hishamco commented Feb 5, 2018

@KathleenDollard I will repeat my question again, If I re-implement the Razor to emit VB instead of C# is that gonna work, or the MVC is tightly coupled on the cshtml C#?

@Eilon
Copy link
Member

Eilon commented Feb 5, 2018

@hishamco that would be a good question for @rynowak . Ryan?

@rynowak
Copy link
Member

rynowak commented Feb 5, 2018

MVC's runtime compilation engine uses the Roslyn infrastructure for compiling C#, and expects/requires the C# project system's settings to be passed through .deps.json. MVC doesn't have any tight coupling to the code that is generated, but rather it provides infrastructure for compiling C# views at runtime using settings generated by a C# project.

Anyone who wants to compile VB at runtime will need to implement a view engine that does that.

@hishamco
Copy link
Member

hishamco commented Feb 5, 2018

Thanks @rynowak for you clarification

uses the Roslyn infrastructure for compiling C#, and expects/requires the C# project system's settings to be passed through .deps.json

If I implement a VB view engine - or clone C# one with modification -, what settings that I need to pass into .deps.json to make this happen?

@neonleo
Copy link

neonleo commented Feb 17, 2018

+1
Visual Basic always the most important language in .NET world. VB still many fans and use today! Although many peoples work in C# project on their work place, but I believe many peoples like me, love to use VB on own project.

@tb-mtg
Copy link

tb-mtg commented Feb 26, 2018

@AnthonyDGreen @KathleenDollard

The .vbhtml razor engine from MVC 5 wasn't ported to Core primarily because less than 1% of all VB web projects used it after 5 versions.

What do the other 99% use then?

@reduckted
Copy link
Contributor Author

Angular, or other similar front-end libraries, I would presume. That's what I use.

@MPCoreDeveloper
Copy link

Actually that is also exactly what I plan to do with our new web projects move to Angular from ASP.Net MVC Razor , I have to do 4 new web projects this year , so if someone keeps count .. LOL

@simonmilne80
Copy link

VB has been a popular language for many years! As a company we certainly have many code snippets that we would not want to have to re-write in C# Im sure there are many old school web form apps that are due to be re-written especially with the new EU rules coming into play, this would mean that VB would be very much wanted! I find it amazing that microsoft blow so hot and cold on VB one minute its being developed on par, next its the poor relative! Yes new languages and frameworks are coming out but dont just ditch the popular old ones!

@tb-mtg
Copy link

tb-mtg commented Mar 18, 2018

Glad it's being tracked here, hopefully might see some action then.

@NatShaw
Copy link

NatShaw commented Jun 6, 2018

All signs (weasel words) from MS are that they plan to dumb-down VB.NET, and/or do nothing and wait for others to write the missing bits. I’m over their weasel words, I’m exiting VB.NET development now.

@tb-mtg
Copy link

tb-mtg commented Jun 6, 2018

I just hope when Microsoft acquires GitHub it doesn't get the same treatment that VB.Net did (being left for dead with empty promises of full support).

@ghost
Copy link

ghost commented Feb 14, 2019

VBLazor would be similar to uwp/wpf design view, but with two code-behind files, one for server vb.net codes, and another for client (script) codes, with the ability to use MVVM pattern to organize large projects. XAML will be complied to html5, Xaml styles will be compiled to CSS, and VB.NET script codes will be compiled to WebAssembly.

@reduckted
Copy link
Contributor Author

I'm closing this because, sadly, it's pretty clear that there is no intention to add VB.NET project templates for ASP.NET Core.

@VBAndCs
Copy link

VBAndCs commented Mar 21, 2019

@reduckted @muratg @tb-mtg @brunojuliao @rynowak @CheungTatMing @VBDotNetCoder @simonmilne80 @NatShaw @SrqComputerguy @sreenathGanga1988 @mcurros @filippobottega @mrjohnr @beefydog @mevdschee @Baner041986 @hannespreishuber @Webbarrr

Finally: A working VB.NET ASP.NET MVC Core Razor sample!
https://github.com/VBAndCs/VB.NET-Razor
I implemented a simple VBRazorViewEngine in the VbRazor project.
To use VBRazorViewEngine in the project, I added these two statements to the Startup.ConfigureServices method:

services.AddTransient(Of IConfigureOptions(Of MvcViewOptions), VBRazor.VBRazorMvcViewOptionsSetup)()
services.AddSingleton(Of IViewEngine, VBRazor.VBRazorViewEngine)()

The VBRazor is just a VB class that implements the IVBRazor Interface:

Public Interface IVBRazor
    ReadOnly Property Razor As String

End Interface

The Razor property uses the xml literals to compose the HTML code and returns it as a string.. Example:

Imports VbRazor

Public Class IndexView
    Implements IVBRazor

    Dim students As List(Of Student)

    Public Sub New(students As List(Of Student))
        Me.students = students
    End Sub

    Public ReadOnly Property Razor As String Implements IVBRazor.Razor
        Get
            Dim x = <html>
                        <h3> Browse Students</h3>
                        <p>Select from <%= students.Count() %> students:</p>
                        <ul>
                            <%= (Iterator Function()
                                     For Each std In students
                                         Yield <li><%= std.Name %></li>
                                     Next
                                 End Function)() %>
                        </ul>
                    </html>
            Return x.ToString()

        End Get
    End Property
End Class

To use the IndexView from the Controller, I passed it to the View method as the model data in the action method, and passed the actual model data to its constructor:

Public Function Index() As IActionResult
    Return View(New IndexView(Students))
End Function

That’s all!! If you run the project, you will see this web page:
VBRazor

This was really easy, but needs more work, so I hope you start contribute to this project to make it a real productive tool!
The first thing to do, it to create a VB.NET template for ASP.NET MVC Core. I had to create a C# project then convert it to VB!

The second thing to do, is to add intellisense support for html attributes in xml literals in VB!

@hishamco
Copy link
Member

Truth view engine need to parse sort of template like what we have seen in Razor or Markdown .. etc, but what you did is easy because the final markup generated from the code behind which is what the generated classes from Razor did

@VBAndCs
Copy link

VBAndCs commented Mar 21, 2019

@hishamco
I did this in a couple of hours, thanks to VB XML literals, which is almost forgotten! I mayself forgot about it until few weeks when I was trying to invint some new syntax to suggest so I wrote and the editor completed it with the closing tag :)
However there is a lot to do to make this idea a complete product. I wish you and others help in this, so we can write real MVC Cpre apps with VB.NET.
There is a room in gitter for VB Volunteers:
https://gitter.im/VB-NET/Volunteer
Thanks.

@hishamco
Copy link
Member

Xml literal is a very good feature that VB only has. Regarding vbhtml it needs time and efforts and I am one of the interested guys from the past, hope if we can start on this soon

@VBAndCs
Copy link

VBAndCs commented Mar 29, 2019

Hi all,
This is a functional VB Razor (Vazor). Have Fun:
https://github.com/VBAndCs/Vazor

@VBAndCs
Copy link

VBAndCs commented Apr 11, 2019

Hi all,
Please support this proposal #9270
It can be the easy alternative to create vbhtml pages.

@Eilon
Copy link
Member

Eilon commented Apr 11, 2019

@VBAndCs , please try to avoid posting on old closed issues. We try to keep this issue tracker for bugs and feature requests in ASP.NET Core and minimize other discussions.

@VBAndCs
Copy link

VBAndCs commented Apr 11, 2019

@Eilon
Sorry, but this is a feature request that doesn't exist yet. Being closed should not bother you,but it is still poping up on google search, so it is important to keep all related info about this topic together.
Anyway,this is my last response in this topic.
Thanks

@mevdschee
Copy link

@VBAndCs, please don't be discouraged by the bossy tone of @Eilon (a Microsoft manager, not a developer, according to his Github bio). I guess he is just using strange words to say "thank you for your awesome contribution".

@VBAndCs
Copy link

VBAndCs commented Apr 12, 2019

@mevdschee
Thanks for your support :). I can imagine the huge pressure @Eilon is under with hundreds of notifications per day, bugs to fix, discussions to make , questions to answer and suggestions to reject 👯‍♂️
So, I will refer to this topic in my mew proposals (which I hope they keep coming until VB.NET restore its righteous place :) ).
I hope Eilon discuss important proposals or at least let them open for a while to allow community to discuss them instead of jumping immediately to the close button.
Thanks again @mevdschee , and sorry @Eilon :)

@simonmilne80
Copy link

I have been following this thread for a long time as a proper full solution really in my opinion should have been on the road map without having to be forced. I was slightly dissapointed though to see after the hard work put in by @VBAndCs that @Eilon would try and stop anyone else trying to help solve the issue for so many people! I can understand there is a lot of pressure, however the fact people are still following this shows its important to a lot of people! Keep up the good work :)

@Eilon
Copy link
Member

Eilon commented Apr 12, 2019

Hi everyone,

We strongly encourage community activity and features, but we cannot accept certain feature requests or bug fixes because they are not a high enough priority for us to implement. This even includes the case where there's a pull request that includes tests and documentation. Making any change of any size has a cost, including long term cost, and we have to balance that against all the other potential work that we are considering. When it comes to view engines, we are 100% committed to the Razor view engine with support for C#, and a great editor experience in Visual Studio, Visual Studio for Mac, and Visual Studio Code.

We believe that there is a great opportunity here for people such as @VBAndCs to create additional projects that work with ASP.NET Core and integrate in a variety of ways. We're happy to link to those projects by having people send PRs to readme files such as the MVC readme.

Thanks,
Eilon

@VBAndCs
Copy link

VBAndCs commented Apr 12, 2019

To @simonmilne80, @mevdschee and any one who is interested:
I added a working example of zml pages to the repo, so please, lets take the discussion to this topic: VBAndCs/Vazor-DotNetCore2#1
and give @Eilon some moments of peace :)

@Eilon
Copy link
Member

Eilon commented Apr 12, 2019

BTW we're looking to add a mention of Vazor to an upcoming ASP.NET Community Standup. Do you have a blog post we can reference in addition to the GitHub repo?

@VBAndCs
Copy link

VBAndCs commented Apr 25, 2019

@Eilon
Sorry for delaying my reply. I needed to complete my work first, and write a readme file containing basic info about ZML tags.
ZML 1.0 now has its own repo and NuGet.
I would approciate if you mention ZML, becuase it is language independent (the repo contains a project sample with c# and VB two versions, and they both use the same .zml files.
Thanks.

@Eilon
Copy link
Member

Eilon commented Apr 25, 2019

This already happened! VBAndCs/Vazor#1

@Gruski
Copy link

Gruski commented Nov 19, 2019

Looking into converting my VB.NET WebForms app to .NET Core Razor Pages. If true that VB will not be supported then what modern ASP.NET path should I migrate to instead? Re-writting the app in C# is not an option.

@Eilon
Copy link
Member

Eilon commented Nov 19, 2019

@Gruski if there's a lot of VB.NET code that is "library" code - that is, not even WebForms-specific - then that all works quite fine in the .NET Core / Razor Pages / Blazor world. It's the WebForms vs. Razor (and Blazor) part that's much more work.

We did just release a preview of an e-book to help developers migrate from WebForms to Blazor:

https://docs.microsoft.com/en-us/dotnet/architecture/blazor-for-web-forms-developers/index

So it might be possible to keep some of your app in VB, and then only the UI would need to be C#.

@VBAndCs
Copy link

VBAndCs commented Nov 19, 2019

So it might be possible to keep some of your app in VB, and then only the UI would need to be C#.

You can use a VB.NEt project for the UI as well. Only the cshtml files will contain C# chunks. If you want to avoid the C# code, you can use xml literals in VB.NEt to design the UI as I did in my Vazor project:
https://github.com/VBAndCs/Vazor-DotNetCore2
Anthony Green took this to another level as you can see in his last topics in his blog:
https://anthonydgreen.net/
Or here:
dotnet/vblang#483
I also suggested to use an XML tag commands to avoid both C# and VB and have a pure XML Razor (I called ZML):
https://github.com/VBAndCs/ZML

@Gruski
Copy link

Gruski commented Nov 20, 2019

Although our project is a WebForms project, we are no longer using it as was originally intended. This was an old but large enterprise application that over the years has been converted to solely use Vue.js client side framework calling WebMethods residing in each of the .aspx code behind pages. So there are: no server components (no runat="server" anything), no viewstate, no full page posts (no "form" element). Other than the Load method which dynamically initializes some Vue client side components, the code behind only contains WebMethods.

With this in mind and the requirement to move to .NET core what new ASP.NET tech should I migrate the project to if I want to get away from WebForms? MVC to me makes no sense since Vue.js already has the MVC pattern on the client side, which is my opinion is more elegant, so why would I need it on the server? Blazor makes no sense either because that would entail rewriting the entire UI again.

@Eilon
Copy link
Member

Eilon commented Nov 20, 2019

@Gruski I would recommend Razor Pages. It's extremely easy to start with: Just created a Pages folder in your ASP.NET Core app and start adding .cshtml files to it. Each page is essentially a URL, and you can put arbitrary HTML in it, then add any C# you want for server logic.

Try this tutorial to get started: https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/razor-pages-start?view=aspnetcore-3.0&tabs=visual-studio

@Gruski
Copy link

Gruski commented Nov 20, 2019

@Eilon Do Razor Pages have code behind to place WebMethods in? Otherwise where would the WebMethods be placed? Looking at it it looks like it still uses a simplified version of server side MVC pattern behind the scenes which is redundant when using Vue. Also no VB support in Razor Pages.

@Eilon
Copy link
Member

Eilon commented Nov 20, 2019

Razor Pages don't support WebMethods. I would recommend using MVC for those methods. You can mix Razor Pages and MVC in the same app.

@KathleenDollard
Copy link

@Gruski I have been travelling and just catching up.

If you have your UI in Vuew.js, can you just use ASP.NET Core MVC/WebAPI? This works fine. While this article is a bit much in including Angular, it does show the general technique: https://devblogs.microsoft.com/vbteam/combining-angular-visual-basic-and-net-core-for-developing-modern-web-apps/

There are two areas of issues with support:

  • Razor is not supported for Visual Basic, although as pointed out @VBAndCs and @AnthonyDGreen have both worked out a potentially better solution for Visual Basic.
  • There are no templates for ASP.NET WebAPI.

@dotnet dotnet locked as resolved and limited conversation to collaborators Dec 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests